Tuple Arguments
suggest changeA 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"
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents