Czy ktoś wie może skąd się to bierze:
class A < BigDecimal
def *(other)
A.new(super(other))
end
end
v = A.new("5") * A.new("6")
v.class #=> BigDecimal ????
Czy ktoś wie może skąd się to bierze:
class A < BigDecimal
def *(other)
A.new(super(other))
end
end
v = A.new("5") * A.new("6")
v.class #=> BigDecimal ????
[code=ruby]require “bigdecimal”
class A < BigDecimal
def *(other)
A.new(super(other))
end
end
v = A.new(“5”) * A.new(“6”)
v.class #=> A[/code]
Ruby 2.0.0p0
Czyli bazia w 1.9.3p392?
(bazia == bazior)
Wygląda na to, że (initializer) A.new(BigDecimal.new(“5”)) zwraca BigDecimal.
1.9.3p374 :001 > require 'bigdecimal'
=> true
1.9.3p374 :002 > class A < BigDecimal; end
=> nil
1.9.3p374 :003 > A.new(BigDecimal.new("5")).class
=> BigDecimal
2.0.0p0 :001 > require 'bigdecimal'
=> true
2.0.0p0 :002 > class A < BigDecimal; end
=> nil
2.0.0p0 :003 > A.new(BigDecimal.new("5")).class
=> A