orlovdn / rambler.ru (Dmitry N Orlov) wrote in message news:<45323c22.0311092310.56710a4e / posting.google.com>...
> gabriele renzi <surrender_it / remove.yahoo.it> wrote in message news:<lv7sqv86nbca1r62cf2hud3u952uv103ov / 4ax.com>...
> I just want return object of the class from object-method times(). See
> TDD, please, to understand me :)
Sorry. It's fine

class Dollar
  attr_reader :amount
  def initialize(amount)
    @amount = amount
  end
  def times(multiplier)
    return Dollar.new(@amount * multiplier) #??????????
  end
end

five = Dollar.new(5)
product = five.times(6)
#Now product is a Instance of Dollar
p product.inspect
p five.inspect
p (product.times(10).inspect)
p product.inspect
p five.inspect

#<Dollar:0x2787810 @amount=30>
#<Dollar:0x27878e8 @amount=5>
#<Dollar:0x2787750 @amount=300>
#<Dollar:0x2787810 @amount=30>
#<Dollar:0x27878e8 @amount=5>