[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:03876] Re: main.method

From: Dave Thomas <Dave@...>
Date: 2000-07-06 15:19:48 UTC
List: ruby-talk #3876
ts <decoux@moulon.inra.fr> writes:

> >>>>> "D" == Dave Thomas <Dave@thomases.com> writes:
> 
> D> A second problem is that methods defined at the top-level are private, 
> D> so they cannot be called with a receiver, so you can't go messing with 
>       ^^^^^^^^^^^^^^^^^^^^^
> [...]
> >> #       public :globalBurp
>    ^
>    |
> [...]
> D> Or am I missing something?
>  
>   You don't need to add the line :
> 
>        public :globalBurp

Actually, it doesn't - there's a call from the class that fails
without this. That's part of what I was trying to illustrate:

     class Fish
       def initialize
         @burp = "burp"
       end
       def burp(global)
         puts global.globalBurp     # <<<<<<<<<<<<<
       end
     end

     @burp = "blop"

     def globalBurp
       p self
       @burp
     end

     public :globalBurp
     puts globalBurp, "\n"

     puts "now I expect fish to (blobal) burp, which means 'blop'"
     Fish.new.burp(self)


Regards


Dave

In This Thread