Suppose that:
class C; end
c = C.new
sing = (class << c; self; end)
If a method is called with C and sing, but I don't know which is first and
which is second in the parameter list, how do I tell them apart?
Thanks,
dean
···
--
Dean Wampler
http://www.objectmentor.com
http://www.aspectprogramming.com
http://aquarium.rubyforge.org
I just figured out a way, if I also have the instance "c".
c.instance_of?(C) # => true
c.instance_of?(sing) # => false
Also works for kind_of? and is_a?
Thanks, Dean! 
···
On 11/2/07, Dean Wampler <deanwampler@gmail.com> wrote:
Suppose that:
class C; end
c = C.new
sing = (class << c; self; end)
If a method is called with C and sing, but I don't know which is first and
which is second in the parameter list, how do I tell them apart?
Thanks,
dean
--
Dean Wampler
http://www.objectmentor.com
http://www.aspectprogramming.com
http://aquarium.rubyforge.org
http://www.contract4j.org
--
Dean Wampler
http://www.objectmentor.com
http://www.aspectprogramming.com
http://aquarium.rubyforge.org
http://www.contract4j.org
"Dean Wampler" <deanwampler@gmail.com> writes:
Suppose that:
class C; end
c = C.new
sing = (class << c; self; end)
If a method is called with C and sing, but I don't know which is first and
which is second in the parameter list, how do I tell them apart?
C.name ==> "C"
sing.name ==> ""
YS
Thanks.
Correction: only instance_of? works. is_a? and kind_a? both return true for
"C" and "sing".
···
On 11/2/07, Yohanes Santoso <ysantoso-rubytalk@dessyku.is-a-geek.org> wrote:
"Dean Wampler" <deanwampler@gmail.com> writes:
> Suppose that:
>
> class C; end
> c = C.new
> sing = (class << c; self; end)
>
> If a method is called with C and sing, but I don't know which is first
and
> which is second in the parameter list, how do I tell them apart?
C.name ==> "C"
sing.name ==> ""
YS
--
Dean Wampler
http://www.objectmentor.com
http://www.aspectprogramming.com
http://aquarium.rubyforge.org
http://www.contract4j.org