Code Editor
Learn
Methods, Blocks, & Sorting

Blocks Are Like Nameless Methods

Most methods that you've worked with have defined names that either you or someone else gave them (i.e. [array].sort(), "string".downcase(), and so on). You can think of blocks as a way of creating methods that don't have a name. (These are similar to anonymous functions in JavaScript or lambdas in Python.)

Blocks can be defined with either the keywords do and end or with curly braces ({}).

Instructions

Check out the examples in the editor. Look familiar? Run the code to see the blocks execute their code.

Report a Bug
If you see a bug or any other issue with this page, please report it here.