Skip to Content
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 ({}).


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

Folder Icon

Take this course for free

Already have an account?