From: Chad Perrin Date: 2012-04-16T02:48:05+09:00 Subject: Re: Why doesn't Fixnum#to_d exist? On Sun, Apr 15, 2012 at 05:35:12AM +0900, Josh Cheek wrote: > On Sat, Apr 14, 2012 at 11:45 AM, Chad Perrin wrote: > > On Sat, Apr 14, 2012 at 07:23:34AM +0900, Mark Campbell wrote: > > > > > > Yes, that file has the String#to_d, Float#to_d and Rational#to_d. > > > Fixnum#to_d is not present. > > > > Strange. It appears you're right. I can do 1.to_d, but I don't know > > what class has the method when I use it like that. > > You can ask the method for its owner to find out > 1.method(:to_d).owner # => Integer Thanks. That's the method I was trying to remember, but it wouldn't come to me. It's pretty strange how this works, though: >> Integer.methods.include? :to_d => false >> 1.method(:to_d).owner => Integer . . . so, because I was using the Integer.methods.include? approach earlier, I didn't find it in Integer either. Shouldn't the class report the method when asked even if it's added by a mixin or straight-up monkeypatch? -- Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]