The 'for i in list' syntax exists in Ruby if you want to just loop over a list. The block syntax though gives you the flexibility to use map/collect, select, reject, or inject instead of plain each over the list to give you some functional advantages.
Comments
The 'for i in list' syntax exists in Ruby if you want to just loop over a list. The block syntax though gives you the flexibility to use map/collect, select, reject, or inject instead of plain each over the list to give you some functional advantages.
Exactly. It's not that Ruby lacks the ability to do some things, but rather, has its own additional idiomatic way of accomplishing the same task.