Shashank Agarwal & Matthias Reitinger wrote:
>
> puts sandy
>
Thank you both that did work, but opened a new issue for me.
When I change the def to_s within the Person class to this (adding the
@address):
========================================================================
def to_s
@first_name + " " + @last_name + "\n" + \
@email + "\n"
@address
end
========================================================================
I get this "#<Person:0x2b3340c>", is this because the Person class makes
reference to the Address class, and its the address class has its own
to_s that prints? Should I move the @street + "\n" + \, ...etc to the
Person class from the Address class?
If I change the def a little to this:
========================================================================
def to_s
@first_name + " " + @last_name + "\n" + \
@email + "\n"
@address + "\n"
end
========================================================================
I get a different error message:
"test_temp1.rb:25:in `to_s': undefined method `+' for
#<Address:0x3413f68> (NoMethodError)
from test_temp1.rb:41:in `puts'
from test_temp1.rb:41"
Thanks!
--
Posted via http://www.ruby-forum.com/.