Rubista: What is it called?

Let's say I have an enumeration pool that I want to group by attribute:

cars = Car.all.group_by(&:color)

Then I want to repeat these carsas follows:

cars.inject([]) do |stack, (color, cars)|
  stack << cars.each do |car|
   ...
  end
end

What is the term for block expansion (between parentheses)?

+3
source share
2 answers

I call it destructuring bind or destructuring assigning, which is usually called in other programming languages. In Ruby, it is often called multiple assignment or concurrent assignment. If you want to know what it “officially” called, you can find it in the “Draft ISO Specification” .

+3
source

, (ML, Haskell ..). Python . , Ruby .

+1

Source: https://habr.com/ru/post/1750604/


All Articles