mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add Complex#to_c method.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user