[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: classless methods

Gavin Kistner

10/27/2006 5:57:00 PM

From: jwmerrill@gmail.com [mailto:jwmerrill@gmail.com] 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)