Code Editor
Learn
Blocks, Procs, and Lambdas

Symbols, Meet Procs

Now that you're learning some of the more complex parts of the Ruby language, you can combine them to work some truly arcane magicks. For instance, remember when we told you that you could pass a Ruby method name around with a symbol? Well, you can also convert symbols to procs using that handy little &.

Check it out:

strings = ["1", "2", "3"] nums = strings.map(&:to_i) # ==> [1, 2, 3]

By mapping &:to_i over every element of strings, we turned each string into an integer!

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