Explicit block arguments

tags: [jason] [blocks]

Quick note on block argument syntax

I was passing in a @data array of arrays from the controller and accessing the contents per item like so.

@data.each do |item|
  puts item[0]
  puts item[1]
  puts item[2]
end

BUT!!!!! I can be more descriptive by labelling out these items explicitly in the args, making sure to add parenthesis () and a labels.

@data.each do |(name, age, spending)|
  puts name
  puts age
  puts spending
end

So much more understandable