Ruby Hash Sugar
Very commonly, we use Ruby hashes as a way to emulate keywords args. The approach goes like:
# These are the same
some_method({ :key => 'value' })
some_method(:key => 'value')
As @0utoftime pointed out recently, this is also possible when using Hashes inside of Arrays:
# These are the same
v = [ { :key => 'value' } ]
v = [ :key => 'value' ]
And, stretching the use even further, mixed in Arrays:
# These are the same
v = [ 1, 2, { :key => 'value' } ]
v = [ 1, 2, :key => 'value' ]
Similar symmetry and sugar is obviously all through the language, but I found this one particularly cool.
Of course, Array also has some tricks:
# These are the same
v = [1, 2]
v = 1, 2
and a few forms of multi-return
# These are the same
temp = a; a = b; b = temp
a, b = b, a
# This is possible
a, b = [1, 2]
# This is possible
num1, num2, hash = [1, 2, :key => 'value']