Redefining hat operator for Proc

B

bparanj

Hello,

I am developing a gem where I need to redefine the <=> operator for
Proc. This operator shows up in the methods list when I print the
output of methods call but I don't see it in the list of private or
protected methods.

I know in Ruby 1.9 === operator has been redefined, but I am not able
to confirm that <=> is currently implemented in Ruby 1.9. I don't want
to over-ride the hat operator if it is already implemented for Proc.
Could someone please give me some pointers?

TIA.
Bala
 
R

Robert Klemme

Hello,

I am developing a gem where I need to redefine the <=> operator for
Proc. This operator shows up in the methods list when I print the
output of methods call but I don't see it in the list of private or
protected methods.

I know in Ruby 1.9 === operator has been redefined, but I am not able
to confirm that <=> is currently implemented in Ruby 1.9. I don't want
to over-ride the hat operator if it is already implemented for Proc.
Could someone please give me some pointers?

If you do Proc.instance_method:)<=>), what do you get? If nil, then
it's not overridden.

Cheers

robert
 
B

bparanj

If you do Proc.instance_method:)<=>), what do you get?  If nil, then
it's not overridden.

Cheers

        robert

irb(main):005:0> p = Proc.instance_method:)<=>)
NameError: undefined method `<=>' for class `Proc'
from (irb):5:in `instance_method'
from (irb):5
from /usr/local/bin/irb:12:in `<main>'

Looks like it is safe to redefine it. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top