What I propose is to translate the construct: ~~~ ruby a = 3 b = [ 2 ] a, b = 2, 3, 4 a == 2 b == 3 # 4 is ignored a, b = 2 a == 2 b == nil ~~~ That's current behaviour if the number of elements is not the sam...najamelan (Naja Melan)
@bug hit My apologies, it seems I'm mistaken. The splat operator does not just seem to coerce into array for all types: ~~~ ruby a = { a: 1 } p [a] # [{:a=>1}] p *a # [:a, 1] p [*a] # [[:a, 1]] ~~~ It seems it calls...najamelan (Naja Melan)
bug hit wrote: > Nobuyoshi Nakada wrote: > ... Actually this is really useful. Whenever a method accepts a `something` or an `array of somethings` you can use the splat operator to make it an array if it's not already. Now you can oper...najamelan (Naja Melan)
~~~ ruby a = [ 'a', 'b' ] b = [ 'c', 'd' ] def c return [ 'A', 'B' ], [ 'C', 'D' ] end a, b += c # -> would be awesome, but gives syntax error a, b = a + c.first, b + c.last # clunky and will call method twice... ...najamelan (Naja Melan)