Tuple Arguments

suggest change

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"

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents