On Mon, Feb 18, 2013 at 8:38 PM, Love U Ruby <[email protected]> wrote:
> @ubuntu:~$ irb --simple-prompt
>>> class Foo
>>> def initialize(x,y,z)
>>> @x, @y, @z= x, y,z
>>> end
>>> def to_ary
>>> [@x, @y, @z]
>>> end
>>> def to_hash
>>> [@x => @y]
>>> end
>>> end
> => nil
>>> foo = Foo.new(10,11,12)
> => #<Foo:0x00000001191738 @x=10, @y=11, @z=12>
>
> My Question is with the below :
>
>>> a,*b = foo
> => #<Foo:0x00000001191738 @x=10, @y=11, @z=12>
>>> a
> => 10
>>> b
> => [11, 12]
>
> How or which internal method has been called to make such assignment to
> a,*b from instance variables?
set_trace_func lambda {|*x| p x}
and investigate yourself.
Cheers
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
--
[email protected] |
https://groups.google.com/d/forum/ruby-talk-google?hl=en
---
You received this message because you are subscribed to the Google Groups
"ruby-talk-google" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.