[#300] Ruby 1.3.3-990507 — matz <matz@...>
Ruby 1.3.3-990507 is out, check out:
1 message
1999/05/07
[#314] Arity features for Proc object? — matz@... (Yukihiro Matsumoto)
A mail from <yeboah@tu-harburg.de> is somehow rejected by the list
12 messages
1999/05/17
[#315] Re: Arity features for Proc object?
— matz@... (Yukihiro Matsumoto)
1999/05/17
[#316] Re: Arity features for Proc object?
— gotoken@... (GOTO Kentaro)
1999/05/17
In message "[ruby-talk:00315] Re: Arity features for Proc object?"
[#318] Re: Arity features for Proc object?
— matz@... (Yukihiro Matsumoto)
1999/05/17
Hi.
[#319] Re: Arity features for Proc object?
— gotoken@... (GOTO Kentaro)
1999/05/17
In message "[ruby-talk:00318] Re: Arity features for Proc object?"
[#320] Re: Arity features for Proc object?
— matz@... (Yukihiro Matsumoto)
1999/05/17
Hi.
[#323] binding — Pros Yeboah <yeboah@...>
Hi
5 messages
1999/05/18
[#357] thinking aloud — "Bryce Dooley" <thecrow@...>
First off, I think Ruby is a very nice scripting language.
7 messages
1999/05/29
[ruby-talk:00335] Re: module-class calling
From:
gotoken@... (GOTO Kentaro)
Date:
1999-05-23 03:23:16 UTC
List:
ruby-talk #335
Hi,
In message "[ruby-talk:00334] Re: module-class calling"
on 99/05/22, "Michael Neumann" <neumann@s-direktnet.de> writes:
>But now I have to declare also the functions, which are called by "hello" as
>module_functions.
>Following example does not work (without :bye):
>
> module A
> def bye
> print "BYE\n"
> end
>
> def hello
> print "HELLO\n"
> bye
> end
>
> module_function :hello #, :bye
> end
>
> class B
> def call_A
> A.hello
> end
> end
>
> x = B.new
> x.call_A
>
>Is the only solution to declare all functions inside the module, which are
>called from a module-function ('hello'),
>as module_function (like 'bye'), even if they are not called from outside
>the module?
Well, the module-function are called only as either a singleton
method of the module or an instance method after including the module.
So, if you want call `hello' as a singleton method and `hello' calls
`bye' you have to put `module_function :bye'.
By the way, I use modules when I want
(1) to provide a name space for the constants,
(2) to let several classes include a same module, or
(3) to define many singleton methods as module_function
The case (2) is known as mixin. You can see an example of the case (3)
in the mathematical modules, e.g., lib/rational.rb etc.
-- gotoken