Crystal: Minor documentation request for 'next'

Created on 1 May 2017  路  2Comments  路  Source: crystal-lang/crystal

In the description for next at:

https://crystal-lang.org/docs/syntax_and_semantics/next.html

It might be helpful to note that next can take a parameter, which will then be the value of that next statement (the same way return does). This is useful to know when writing a code block for something.reduce{}, for instance, where it's probably important that the code block not return a nil.

Hmm. Is this also true for the break statement?

Most helpful comment

Hmm. Is this also true for the break statement?

AFAIK yes.

See https://play.crystal-lang.org/#/r/1yic

All 2 comments

Hmm. Is this also true for the break statement?

AFAIK yes.

See https://play.crystal-lang.org/#/r/1yic

Thanks @drosehn! We've got a specific repo for these issues (see above). Please next time open it there. I just opened an issue referencing this on https://github.com/crystal-lang/crystal-book/issues/97.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xtagon picture xtagon  路  132Comments

asterite picture asterite  路  70Comments

chocolateboy picture chocolateboy  路  87Comments

asterite picture asterite  路  78Comments

sergey-kucher picture sergey-kucher  路  66Comments