Destructuring Block Arguments
suggest changetriples = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
triples.each { |(first, second, third)| puts second }
# 2
# 5
# 8
triples.map { |(first, *rest)| rest.join(' ') } # => ["2 3", "5 6", "8 9"]
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents