Re: classless methods

From: Nick S. [mailto:[email protected]]

Actually, it looks like it becomes a public instance method of Object:
[snip]
irb is messing with your head here. Try the same as a standalone Ruby
program:

def hello; end
p self.class
#=> Object
p self.public_methods.include?(“hello”)
#=> false
p Object.private_methods.include?(“hello”)
#=> true
p Object.private_instance_methods.include?(“hello”)
#=> true
p Object.public_instance_methods.include?(“hello”)
#=> false
p (class << self; self; end).public_instance_methods.include?(“hello”)
#=> false

On 10/27/06, Gavin K. [email protected] wrote:

From: Nick S. [mailto:[email protected]]

Actually, it looks like it becomes a public instance method of Object:
[snip]
irb is messing with your head here. Try the same as a standalone Ruby
program:

Good catch, thanks for the correction.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs