Re: a = Dog.new # a is not a pointer and not a reference?



On 9/30/07, SpringFlowers AutumnMoon <summercoolness@xxxxxxxxx> wrote:

how about just a.set_value(3) vs a->set_value(3). what i mean is just
the "." and "->" difference. using a "." in Ruby and "->" in C or C++.
If I think of "a" as a pointer and "." as "->", will that get in trouble
and have any discrepancy for other things.
Yup 'cause '.' is not dereferencing period (pun intended). It is
sending a message

x.a is almost equivalent to
x.send :a.

Variables in Ruby are references, period again ;) but you cannot
dereference them.
I guess this was somehow lost in the discussion.

HTH
R.
--
what do I think about Ruby?
http://ruby-smalltalk.blogspot.com/

.



Relevant Pages

  • Re: Tree structure - how do we link nodes together?
    ... Robert Klemme wrote: ... Ruby does not have the multitude of options that C++ has. ... It helps me to think of references and the objects they point to as ... altered or corrupted during transmission. ...
    (comp.lang.ruby)
  • Re: Simple question regarding hashes
    ... >> ruby test1.rb ... You end up with the same hash ... note that %wis an array literal equivalent to ... unknowingly having two references to the same object can cause ...
    (comp.lang.ruby)
  • Re: A crosspost from the Perl Community
    ... references/pointers would sometimes be more elegant. ... so Java / Ruby already that I simply do not think in ways that would ... these are as elegant as an lvalue reference IMHO. ... :-) But I can see how this might be a bit more elegant with references. ...
    (comp.lang.ruby)
  • Re: a Python persons experience with Ruby
    ... That's not to say it's better than python (like I ... syntax in ruby, ... making method references use it also allows them to ... a method itself should be callable without parens ...
    (comp.lang.python)
  • Re: `finalize method?
    ... method is done executing, since the Klass instance has already been deemed ready for destruction. ... Seems to me Ruby would have to scan all of the current image to determine if any new references were created during the execution of the finalize method. ...
    (comp.lang.ruby)