TIL: Ruby Methods Can Take Tuples
Filed in the interesting but don't use category of fun Ruby things, but method arguments can be tuples
Filed in the interesting but don't use category of fun Ruby things, but method arguments can be tuples.
def ingredient(name, (quantity, unit))
puts "#{quantity}#{unit} of #{name}"
end
ingredient('gin', ['20', 'ml'])
# 20ml of gin
Member discussion