I think splats are only available in assignments (and indirectly, in method calls). You can't call splat directly either:
1.9.3p286 :045 > *[1,2,3,4]
SyntaxError: (irb):45: syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'
from /Users/fcoury/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in `<main>'
In your case, you can do something like:
def initialize(opts={})
@ivar = *(opts[:variable_length_opt] ? opts[:variable_length_opt] : [default_value])
end
That is almost as short.
But you usually use the splat to assign multiple variables from an array, like
a = [1,2,3,4]
b, c, d, e = *a
b #=> 1
c #=> 2 ...
Why do you need the splat in this case?