3 ms·
Otherwise you couldn't drop the braces like you currently can when passing hashes to functions. x, y = 1, 2 puts x: x, y: y # ==> {:x=>1, :y=>2}
by pxeger1 5y ago
Otherwise you couldn't drop the braces like you currently can when passing hashes to functions.
x, y = 1, 2
puts x: x, y: y
# ==> {:x=>1, :y=>2}
puts x:, y:
# ==> {:x=>1, :y=>2}
puts x, y
# ==> 1, 2
Which would be inconsistent and annoying.
(and knowing Ruby, I imagine there might be some syntactical ambiguities as well)
- soheil 5y agoI'm ok with having x:, y: but couldn't they drop the : if there are braces to indicate this is a hash? {x, y}