Ruby Language Tuple Arguments


Example

A method can take an array parameter and destructure it immediately into named local variables. Found on Mathias Meyer's blog.

def feed( amount, (animal, food) )

    p "#{amount} #{animal}s chew some #{food}"

end

feed 3, [ 'rabbit', 'grass' ] # => "3 rabbits chew some grass"