3 ms·
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, r
by jdminhbg 18y ago
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.
- wfarr 18y agoExactly. 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.