On 4/7/07, Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
> Hi,
>
> In message "Re: defined? operator changed in ruby 1.9: bug or feature?"
>     on Sat, 7 Apr 2007 08:28:25 +0900, "Rick DeNatale" <rick.denatale / gmail.com> writes:
>
> |So even in 1.8, although the define? a=1 isn't performing the
> |assignment, it IS defining the variable.
> |
> |Is this the way it should work?
>
> Yes.  Assignments shall introduce new variables, no exception.  It's
> like
>
>   if false
>     v = 5
>   end
>
> defines a variable v.

Yes, I understand that.

I guess my surprise is that I think of define? as being an operator
which operates on syntax.  Since the original issue in this thread was
that

defined? a = 1

was setting a to 1, and that seemed to be considered a bug.  I'd
expected that it shouldn't define a either.

But thinking it trough a little bit, I guess that it's consistent with
the parser defining a variable when it has seen it with enough context
to know what it is, i.e. in the case of a 'bareword' to determine if
it's a local or a method name.

Just one of those little lovable quirks of Ruby. <G>

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/