From: Raul Parolari Date: 2009-12-02T01:56:39+09:00 Subject: Re: Splat array with 1 value in Ruby 1.9 vs Ruby 1.8 Robert Klemme wrote: > 2009/12/1 Raul Parolari : >>> >>> >> >> >> �a = *[ 3 ] � # => a = [ 3 ] � �with Ruby 1.9.1 >> >> I think that this is a bug in Ruby 1.9. > > Regardless whether it is or is not a bug (I would not be so sure of > that), there is a way to fix it and handle it uniformly across Ruby > versions: > > 17:31:18 test$ allruby -e 'a = [123];b = *[456];c, = [789]; p a,b,c' > CYGWIN_NT-5.1 padrklemme1 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin > ======================================== > ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin] > [123] > 456 > 789 > ======================================== > ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-cygwin] > [123] > [456] > 789 > ======================================== > jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java > HotSpot(TM) Client VM 1.6.0_17) [x86-java] > [123] > 456 > 789 > > Look at variable "c". > > Kind regards > > robert Indeed, this solves with grace the problem in the automation (without the easy but disturbing question on "how many elements the array has"): a,b, = [ 3, 4 ] # => a = 3; b = 4 a, = [ 3 ] # => a = 3 On the other matter ( a = *[ 3 ] ), I still think that it is a bug in 1.9 (else I don't understand fully what a splat operator is, and I'd like to know more). But thanks a lot, Robert Raul Parolari -- Posted via http://www.ruby-forum.com/.