map

Ruby Code blocks (called closures in other languages) are definitely one of the coolest features of Ruby. They are chunks of code between braces `{}` or between `do..end` that you can associate with method invocations, almost as if they were parameters. A Ruby block is a way of grouping statements, and may appear only in the source adjacent to a method call; the block is written starting on the same line as the method call's last parameter (or the closing parenthesis of the parameter list). The code in the block is not executed at the time it is encountered. Instead, Ruby remembers the context in which the block appears (the local variables, the current object, and so on) and then enters the method. Read more about blocks here, or checkout our examples that make much use of blocks.