On Mon, Jul 22, 2013 at 2:26 PM, Graham Ashton <[email protected]> wrote:

> On 22 Jul 2013, at 13:46, Francis Fish <[email protected]> wrote:
>
> >> I (also?) thought you were trying to use this a shorthand for
> `bus.tell(:turn_on)`, is that not what you meant?
> >
> > Bus is just distributing the turn_on message to its listeners? So not
> modifying self per se.
>
> What I meant was that self would be different at A and B:
>
>   # A
>   with bus do
>     # B
>     tell :turn_on
>   end
>
> As self is the receiver of any implicit method calls, you have to change
> it within the scope of the block or `.tell` won't get called on `bus`.
>
> As Lee said, it's evil. It's not obvious to the reader that you've changed
> self, and all sorts of weird things can happen (to somebody else) down the
> line.
>
>
slaps head - ah right - self becomes bus (or some such) ... doesn't feel
*too* dangerous, but of course you may have defined a tell method that's
what you really want calling ... or some other madness. Of course, Rails
has lots of this and it *is* hard to debug. Understanding dawns.

-- 
You received this message because you are subscribed to the Google Groups 
"NWRUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nwrug-members.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to