> >> To a large extent, my reaction to all of these examples
> comes
> >> down, as
> >> it often does, to the question: how would I explain this
> to
> >> someone to
> >> whom I was teaching Ruby (in person or in writing)?  I
> think
> >> I would
> >> find it quite difficult to explain that in this:
> >>
> >>    s = "hi"
> >>    t = s
> >>    (s) = "bye"
> >
> > I think this is a good example to show the difference.
> > Programmers need to understand the difference shown above. 
> One
> > assigns to a variable and one assigns into an object that a
> > variable has.  Both are normal things you would want to do
> and
> > both are assignment-like.
> 
> "an object that a variable has"?  Variables refer objects but
> they don't 
> exactly *have* them.

Bad wording - sorry.

> I have to admit that I find the third
> line of the 
> example above very confusing.  One of the reasons might be
> that there is a 
> quite similar construct - apparently with different
> semantics:
> 
> >> (a,b)=%w{a b}
> => ["a", "b"]
> >> a
> => "a"
> >> b
> => "b"
> 
> >> (a,)=%w{a b}
> => ["a", "b"]
> >> a
> => "a"

And with what I proposed add to that list (assuming the
()/default/null method is replace):

>> (a) = %w{a b} # a.replace(%w{a b})
TypeError: cannot convert Array into String
>> (a),(b) = %w{a b} # a.replace("a"); b.replace("b")
> => ["a", "b"]
> >> a
> => "a"

This doesn't collide with any syntax, but I could see confusion
especially in light of the existing multi-assignments.

> IMHO Ruby has the right balance between no operator
> overloading at all 
> (Java) and too much operator overloading (C++).

Obviously I would like a little more, but Ruby is the closest
to my tastes also.

> Another note: as far as I remember there are plans to make ()
> work for 
> lambdas.  So currently we have
> 
> >> f = lambda {|x| x+x}
> => #<Proc:0x100c3e60@(irb):15>
> >> f[10]
> => 20
> >> f.call 10
> => 20
> 
> Then we had additionally
> 
> >> f(10)
> => 20

Cool.  So, this sounds like the ()/null operator is being
implemented with procs/lambdas.  Now if we could just have it
for the rest of the objects.



		
__________________________________ 
Yahoo! Mail Mobile 
Take Yahoo! Mail with you! Check email on your mobile phone. 
http://mobile.yahoo.com/learn/mail