diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-02-05 21:42:42 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-02-05 21:42:42 +0900 |
| commit | 7ce03e32b7b21ae7f095dbc23b23497143919b01 (patch) | |
| tree | f907d4db4790191a0d9df70d2d48a46750e2bafb /mrbgems/mruby-complex | |
| parent | ee3017496ba60ca418b5e54c1f8f5d8b38524a52 (diff) | |
| download | mruby-7ce03e32b7b21ae7f095dbc23b23497143919b01.tar.gz mruby-7ce03e32b7b21ae7f095dbc23b23497143919b01.zip | |
Add `Complex#to_c` method.
Diffstat (limited to 'mrbgems/mruby-complex')
| -rw-r--r-- | mrbgems/mruby-complex/mrblib/complex.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mrbgems/mruby-complex/mrblib/complex.rb b/mrbgems/mruby-complex/mrblib/complex.rb index 67f940865..26a3b206f 100644 --- a/mrbgems/mruby-complex/mrblib/complex.rb +++ b/mrbgems/mruby-complex/mrblib/complex.rb @@ -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) |
