From: Alex Young Date: 2007-12-07T20:33:12+09:00 Subject: Re: function like "function_exits" Robert Dober wrote: > On Dec 7, 2007 8:35 AM, Peter Bunyan wrote: >>> Thanks for your answer Robert. >>> It's not a method but a simple function like >>> def foo() >>> #some code >>> end >>> >>> is there something like : >>> functions.exist?('foo') >> A method and a function are the same thing. Also, check this out. >> >> def foo >> puts "Foo is being called." >> end >> >> methods.include? "foo" >> => true > you surely mean false here, right? > the methods method of the toplevel does not seem to include the user > defined methods, or is this just a bug? They're included in IRB: irb(main):001:0> def foo irb(main):002:1> puts "Foo is being called" irb(main):003:1> end => nil irb(main):004:0> methods.include? "foo" => true but not in a script: alex@shaxam:~$ cat toplevel.rb def foo puts "Foo is being called" end p methods.include?("foo") alex@shaxam:~$ ruby toplevel.rb false -- Alex