Unexpected results from private_methods

James D. M. wrote in post #1010480:

  [..., :Integer, :Float, :String, :Array, ..., :Rational, :Complex,
...]

Apparently, I don't understand something. I thought these were standard
classes. Why do they show up here as methods?

They are methods in the Kernel module. Method names with a capital
initial are unusual, but allowed.

irb(main):005:0> Kernel.methods.grep(/^[A-Z]/)
=> ["Array", "Integer", "Float", "String"]
irb(main):006:0> Integer("123")
=> 123
irb(main):007:0> Integer("0123")
=> 83
irb(main):008:0> Integer("0x123")
=> 291

···

--
Posted via http://www.ruby-forum.com/\.

Brian Candler wrote in post #1010558:

They are methods in the Kernel module.

Aha! And those Kernel methods are the default conversions.

BUT . . .

I thought Kernel was mixed in to Object. Why do these appear as
private_methods of BasicObject?

j

···

--
Posted via http://www.ruby-forum.com/\.

James D. M. wrote in post #1010580:

Brian Candler wrote in post #1010558:

They are methods in the Kernel module.

Aha! And those Kernel methods are the default conversions.

BUT . . .

I thought Kernel was mixed in to Object. Why do these appear as
private_methods of BasicObject?

BasicOjbect is a Class, and a Class is an Object.

···

--
Posted via http://www.ruby-forum.com/\.