From: Hans Mackowiak Date: 2013-02-19T16:26:06+09:00 Subject: Re: splat operator and Ruby instance variable assignments Love U Ruby wrote in post #1097729: > Now I have tried the below : > > > C:\>irb --simple-prompt >>> class Foo >>> def initialize(x,y,z) >>> @x, @y, @z= x, y,z >>> end >>> def to_hash >>> [@x => @y] >>> end >>> end > => nil >>> foo=Foo.new(10,11,12) > => # >>> a,*b=foo > => # >>> a > => # >>> b > => [] >>> > > Here the results are not same as with the above. So is it calling my > first instance method automatically? Couldn't understand the logic. WHY do you think that? why you dont get the IDEA that it MAYBE calls to_ary? becaue *arg is the Splat Operator that parts Arrays into members, and MAYBE it calls to_ary is the object is not an Array? -- Posted via http://www.ruby-forum.com/.