Crystal: Iterate through array and return itself

Created on 24 Aug 2017  路  6Comments  路  Source: crystal-lang/crystal

Most helpful comment

I added a section to Crystal for Rubyists: https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists#each-returns-nil

All 6 comments

In https://github.com/crystal-lang/crystal/pull/3815#issuecomment-269978574 you can find an explanation about why it is preferred to return nil instead of self for #each.

@bcardiff I don't mind having nil #each, my propose is to add another method like each_and_self, so one doesn't tap &.each every time or even writes his own method.

BTW, now I see that tap &.each is short enough :thinking:

UPD: Okay, I'm totally alright with tap &.each, but this can be confusing for former Rubyists like me...

@vladfaust ok, I didn't understand that you were proposing and addition. I agree that tap &.each is short enough.

Maybe the actionable here is to add an iteration section in https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists .

I believe that this issue should be closed, tap is OK.

I added a section to Crystal for Rubyists: https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists#each-returns-nil

thx @Fryguy

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oprypin picture oprypin  路  3Comments

relonger picture relonger  路  3Comments

ArthurZ picture ArthurZ  路  3Comments

will picture will  路  3Comments

pbrusco picture pbrusco  路  3Comments