Skip to content

Instantly share code, notes, and snippets.

@orend
Created September 22, 2012 18:15
Show Gist options
  • Save orend/3767279 to your computer and use it in GitHub Desktop.
Save orend/3767279 to your computer and use it in GitHub Desktop.
ruby's magic underscore
people = {
"Alice" => ["green", 34, "alice@example.com"],
"Bob" => ["brown", 27, "bob@example.com"]
}
# No problem. Just re-use the underscore:
people.map { |name, (_, _, email)| [name, email] }
a, _, b, _, c = [1, 2, 3, 4, 5]
a # => 1
b # => 3
c # => 5
a, *, b = [1, 2, 3, 4, 5]
a # => 1
b # => 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment