色々と手を動かしてみた
たぶん以下が問題に出そうかな?
- Integer
- Float
- Ratinal
- Complex
と考え、Ruby Goldを受ける前に
手を動かした結果を残しておきます。
integer = 1 + 2
p integer.class
# =>Integer
p Integer.superclass
# => Numeric
p Integer.ancestors
# => [Integer, Numeric, Comparable, Object, Kernel, BasicObject]
float = integer + 1.0
p float.class
# => Float
p Float.superclass
# => Numeric
p Float.ancestors
# => [Float, Numeric, Comparable, Object, Kernel, BasicObject]
rational = integer + 1r
p rational.class
# => Rational
p Rational.superclass
# => Numeric
p Rational.ancestors
# => [Rational, Numeric, Comparable, Object, Kernel, BasicObject]
float2 = float + rational
p float2.class
# => Float
complex = float + 2i
p complex.class
# => Complex
p Complex.superclass
# => Numeric
p Complex.ancestors
# => [Complex, Numeric, Comparable, Object, Kernel, BasicObject]
complex2 = rational + 2i
p complex2.class
# => Complex
RubyGoldに挑戦した結果
Ruby Goldのその後はこちらからどうぞ。
「Ruby Goldを受けてきたお話」