From: Sam Roberts Date: 2004-03-20T06:41:54+09:00 Subject: Re: Defining methods outside classes Wrote Imobach Gonz�lez Sosa , on Sat, Mar 20, 2004 at 05:48:14AM +0900: > Hi all, > > I've got a little curiosity about defining methods. As far as I know (and > maybe I'm wrong) functions doesn't exist in Ruby... right? Ruby only have > methods. It's a method of Object: irb(main):001:0> def foo; end => nil irb(main):002:0> Object.methods => ["send", "name", "class_eval", "object_id", "autoload?", "new", ...... "display", "foo", ">=", "respond_to?", "instance_method", "<=", ^^^^^^ "const_defined?", "instance_of?"] irb(main):003:0> You are in the context of an object of class Object, so you can call foo without specifying a receiver, so it looks like a "function", but its a method of your class. This has got to be a FAQ, check the FAQ at ruby-lang.org. Cheers, Sam -- Sam Roberts