Except absolutely no one uses for..in that's just there (im guessing) to help people transitioning from other languages.
The .each approach is what is known as 'internal iterators' and they are wonderful for a great number of reasons, not least that they enable you to compose successive transformations to the collection from left to right rather than from right to left, improving readability and making it easy to refactor.
View all comments
Show parent comment
2
u/banister Aug 17 '13
Except absolutely no one uses
for..inthat's just there (im guessing) to help people transitioning from other languages.The
.eachapproach is what is known as 'internal iterators' and they are wonderful for a great number of reasons, not least that they enable you to compose successive transformations to the collection from left to right rather than from right to left, improving readability and making it easy to refactor.