I am learning Ruby OOP and have been faced with the following question.
What could we add to the class below to access the instance variable @volume?
class Cube def initialize(volume) @volume = volume end end My initial thought was to add attr_reader :volume to access the instance variable.
Instead the model answer suggests adding a new method as below.
def get_volume @volume end Why is this the preferred method? Both methods would output 100 if cube.volume or cube.get_volume were called.