Collect Method vs Each Method


What is the benefit of using one versus the other? Don't they accomplish the same thing?



You can use either, but they behave differently and one of them may be better suited to what you are writing.

Collect also has a second name, map (same method)

You'd use collect/map for applying some action to each value and obtaining a new array with the results in, but you can read as much in their descriptions, right?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.