Hello. I'm Ruby beginner, I'm not getting proper output, of course it's
problem in my code not in Ruby itself.
Anyone can help to fix this?
The out put should be:
The Dark Knight Rises | Release Date: 2013 | Rating: 7.
But I'm also getting this "#<Movie:0x102b26620>" thing. Anyone can help
me why this is coming even after I used "to_s" ? your help will be
appreciated.
···
===============
class Movie
def initialize(title, date, rating) @title = title @date = date @rating = rating
end
Hello. I'm Ruby beginner, I'm not getting proper output, of course it's
problem in my code not in Ruby itself.
Anyone can help to fix this?
to_s must *return* the string, not print it out.
Just remove the 'puts'.
Carlo
···
Subject: Ruby Class Help
Date: gio 12 set 13 07:32:25 +0200
--
* Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
* di parlare tanto di amore e di rettitudine? (Chuang-Tzu)
Subject: Ruby Class Help
Date: gio 12 set 13 07:32:25 +0200
Quoting Rocky D. (lists@ruby-forum.com):
Hello. I'm Ruby beginner, I'm not getting proper output, of course it's
problem in my code not in Ruby itself.
Anyone can help to fix this?
to_s must *return* the string, not print it out.
Just remove the 'puts'.
Carlo
Yes, removed 'puts' and problem solved! Another thing I was doing wrong
was using "@rating += @rating" I've no idea why did I wrote that! it
should be "@rating += 1" same for thumbs down method.
Thank you Carlo for help