The object vet
can call a method called each
, it works very similar to for
and could be replaced by him. This syntax refers to the object-oriented paradigm in which the object serves as the basis for performing a custom task. Is there a gain? In my opinion no. There is a loss of performance and the syntax gets weirder, as is being observed there.
All that is between keys is a function like any other but with a different syntax because it is an anonymous function. It has no name, only the body, and can be called syntax lambda.
The |e|
is the parameter that this function will receive. Whoever calls this function and sends an argument to it is the each()
that the language provides is basically the only thing it does, sweeps the entire object sending one item at a time to the function you wrote there. The rest is equal to any function. And obviously within the vector there is a permutation (calling the same function recursively) and the result it makes one more execution loop.
He uses the operator <<
which is the same as saying that a append, that is, it adds items in a vector.
This is called callback.
I think it’s more logical.
<<
adds an item in an array. The sum of arrays results in a single array, i.e.:[1] + [1] ==
[1, 1]`.– vinibrsl