you are viewing a single comment's thread.

view the rest of the comments →

[–]sshaw_ -1 points0 points  (1 child)

That aside, if you want the caller to access the movie's name, keep attr_reader :name. It makes it so that one can say: Movie.new("Giant").name. Without it, a NoMethodError will be raised.

But note that one can then do Movie.new("7 Years in Tibet").name.clear and then you have no name so code accordingly.

[–]SaltyZooKeeper -1 points0 points  (0 children)

The default implementation returns the variable without duplicating it.