From: Dave B Date: 2009-12-21T15:48:19+09:00 Subject: [ruby-core:27263] [Bug #2422] splat operator fails on array of 1 element Issue #2422 has been updated by Dave B. Tanaka Akira wrote: > 2009/12/21 katz bo : >> I personally think *[1, 2, 3] should be always unpacked first. >> >> a = *[1, 2, 3] #(unpack Array due to *) should be equal to: >> a = 1, 2, 3 #(as Ruby is very smart) is equal to: (this is really the tricky part) >> *a = 1, 2, 3 #which packs 1, 2, 3 into Array a. Hence is equal to >> a = [1, 2, 3] >> >> a = *[1] #(unpack Array due to *) should be equal to: >> a = 1 #(again, Ruby is smart it won't read this as *a = 1) > > Your way cannot interpret a = *[]. > > a = *[] > a = > > It is not a valid Ruby statement. I would expect to see the value of the first element in the empty array as 1.8.6 provides ... puts 'ruby %s (%s) [%s]' % [RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM] a = *[] p a a = [][0] p a # ruby 1.8.6 (2008-08-11) [i386-mswin32] # nil # nil # ruby 1.9.2 (2009-05-19) [i386-mswin32_90] # [] # nil I understood your last reply to me about "a, =" in multiple assignment with a single RHS but, to me, "a = 1" is multiple assignment with balanced (single) LHS/RHS. Producing an empty array from a splatted empty array seems unproductive. ;) daz ---------------------------------------- http://redmine.ruby-lang.org/issues/show/2422 ---------------------------------------- http://redmine.ruby-lang.org