From: sur max Date: 2007-02-16T05:55:50+09:00 Subject: Re: is it behaving strange ? ------=_Part_60938_3660049.1171572946897 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline gr8... sounds satisfactory !! i will try it on 1.9 Thanks a lot to all !! On 2/16/07, dblack@wobblini.net wrote: > > Hi -- > > On Fri, 16 Feb 2007, sur max wrote: > > > if we even consider it this way .... > > *a = 9 > > a << 5 > > i mean a = [9,5] > > > > and now considering it as... > > > > a # => [9,5] > > *a # => 9,5 --- (on assignment) > > > > so the following should be true > > > > b = a # => [9,5] ----- true > > b = *a # => [9,5] ----- true , b is re-wrapping 9,5 as [9,5] > > b = [a,6] # => [[9,5],6] ---- true, naturally > > b = [*a,6] # => [9,5,6] ----- false, compile error > > b = *a,6 # => [9,5,6] ----- false, compile error > > In Ruby 1.8 and earlier, you can only do the * at the end of an array. > That's changing, though. This is from a November version of Ruby 1.9: > > irb(main):001:0> a = [9,5] > => [9, 5] > irb(main):002:0> b = 9,5,6 > => [9, 5, 6] > irb(main):003:0> b = *a, 6 > => [9, 5] > irb(main):004:0> b = [*a, 6] > => [9, 5, 6] > > I don't really understand the third one. I would have expected it to > be the same as the second. I haven't tried a more recent 1.9 version, > though -- maybe it's been changed. > > > David > > -- > Q. What is THE Ruby book for Rails developers? > A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) > (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) > Q. Where can I get Ruby/Rails on-site training, consulting, coaching? > A. Ruby Power and Light, LLC (http://www.rubypal.com) > > -- sur http://expressica.com ------=_Part_60938_3660049.1171572946897--