Add `Complex#to_c` method.

parent ee301749
......@@ -97,6 +97,10 @@ class Complex < Numeric
end
alias_method :rect, :rectangular
def to_c
self
end
def to_r
raise RangeError.new "can't convert #{to_s} into Rational" unless imaginary.zero?
Rational(real, 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment