foreach vs someList.ForEach(){}

There are apparently many ways to iterate over a collection. Curious if there are any differences, or why you’d use one way over the other. First type: Other Way: I suppose off the top of my head, that instead of the anonymous delegate I use above, you’d have a reusable delegate you could specify…

What does the “map” method do in Ruby?

The map method takes an enumerable object and a block, and runs the block for each element, outputting each returned value from the block (the original object is unchanged unless you use map!): Array and Range are enumerable types. map with a block returns an Array. map! mutates the original array. Where is this helpful, and what is the difference between map! and each? Here is an example: … Read more