Understanding functions under ruby

Hi

Why func.type (or self.func.type) doesn’t work (when func is a function)?
I’ve understood (even if i
don’t like) the python way where there is a class “function”, but i don’t
understand the ruby way.
I’ve read that the difference between a function and a method is only from
where u call it (method from outside, function inside the class). I’m right?
How access to functions ?
I would like to read something clear about the difference between proc,
method and there use. An article about that exists ?
Especially the use of ‘:’, ‘&’, the class Symbol, Proc, Method, Block,
Binding.

Regards.

···


Cedric Foll

Cédric Foll wrote:

Hi

Why func.type (or self.func.type) doesn’t work (when func is a function)?

This returns the type of the value returnd by func.

I’ve read that the difference between a function and a method is only from
where u call it (method from outside, function inside the class). I’m right?

There is no difference between functions and methods. Each function is
a method of the main object.

I would like to read something clear about the difference between proc,
method and there use. An article about that exists ?
Especially the use of ‘:’, ‘&’, the class Symbol, Proc, Method, Block,
Binding.

Pickaxe book: Programming Ruby (by the Pragmatic Programmers)

Regards, Christian

Hello –

Hi

Why func.type (or self.func.type) doesn’t work (when func is a function)?

If func is a method call, then you’re calling type on the return value
of the call. It should work OK, on that basis.

I’ve understood (even if i
don’t like) the python way where there is a class “function”, but i don’t
understand the ruby way.
I’ve read that the difference between a function and a method is only from
where u call it (method from outside, function inside the class). I’m right?
How access to functions ?

I don’t remember there being such a distinction in Ruby. There are
class methods and instance methods (and procs and blocks), but I think
that’s it. (Maybe “function” is sometimes used informally as a
synonym for “method”?)

David

···

On Sat, 7 Sep 2002, Cédric Foll wrote:


David Alan Black | Register for RubyConf 2002!
home: dblack@candle.superlink.net | November 1-3
work: blackdav@shu.edu | Seattle, WA, USA
Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com