On 9/6/07, Pe?a, Botp <botp / delmonte-phil.com> wrote:
> From: John Browning [mailto:listguy / poplar.com]
> # So why doesn't arg2 read its right-hand side  as an array when arg3 does?
>
> many times, if you think ruby, think ruby objects,.. then everything looks so clear...
>
> ruby treats x (like all others) as an object, and the = as the method.
> so let that x=1 be x.=(1)

Actually, not really.

In the statement

  x = 1

While 1 is indeed an object, x is a variable.  Now after that
statement is executed x will be BOUND to the object 1, but there's no
method involved in evaluating x = 1.

I've seen a lot of confusion in ruby-talk over variables vs. objects.
Note that an assignment may cause a method invocation such as in the
cases:

class A
  attr_accessor :x
end

A.new.x = 1

or:

h = Hash.new(42)

h[5] = 10

The fact that ruby assignments either send a "setter" message or not
depending on the definition of the lhs of the assignment, is an
undercurrent to the recent ruby-talk thread about the semantics of
h[5] ||= 10 given the definition of h above.

That all said just why DOES Ruby interpret

arg1="Ruby", arg2="Rails", arg3="Rails"

as

  arg1 = ("Ruby",(arg2="Rails"),(arg3="Rails")


The answer lies in Ruby's parser rather than with objects and variables.
-- 
Rick DeNatale

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