Alex Young
12/7/2007 10:14:00 AM
Girard Fred wrote:
> 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
>>
>> method("foo").call
>> "Foo is being called."
>
> Thanks a lot Peter, it's the answer i m looking for;)
> Just one thing:
> a method, for me, is 'function or procedure' from an object
> a function (standalone one) is some instructions that returns a result
> a procedure (standalone one) execute instructions without necessary
> returns result
>
> It wrong or old scool ?;)
In Ruby, it is not possible for a function to exist without being
attached to an object; all functions are methods. Also, every method
returns a value; all procedures are functions.
--
Alex