Re: classless methods

From: [email protected] [mailto:[email protected]] On

And since Object is an ancestor of pretty much everything in ruby,
it’s interesting to note that these methods are now defined for
practically everything in ruby:

[snip]

You’re being fooled by some tricks that irb plays to make itself work.

In non-irb, these methods are private methods of Object, and not
immediately callable:

def say_hello; “Hello”; end
[1,2,3].say_hello
#=> tmp.rb:2: private method `say_hello’ called for [1, 2, 3]:Array
(NoMethodError)