diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-07-18 00:34:08 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-07-18 00:34:08 +0900 |
| commit | 2a410c0e1b33083402c02d8d8ae3fc99082ec8c3 (patch) | |
| tree | 120fdbb880253b2b6df2fc21582fa2a493ab0b51 /mrbgems/mruby-complex | |
| parent | 0b5e15501671422e5badbb9890904a3e82063bda (diff) | |
| download | mruby-2a410c0e1b33083402c02d8d8ae3fc99082ec8c3.tar.gz mruby-2a410c0e1b33083402c02d8d8ae3fc99082ec8c3.zip | |
Avoid making top-level `env` in initialization code; ref #4581
Diffstat (limited to 'mrbgems/mruby-complex')
| -rw-r--r-- | mrbgems/mruby-complex/mrblib/complex.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/mrbgems/mruby-complex/mrblib/complex.rb b/mrbgems/mruby-complex/mrblib/complex.rb index 0299e7675..1a6f7e92e 100644 --- a/mrbgems/mruby-complex/mrblib/complex.rb +++ b/mrbgems/mruby-complex/mrblib/complex.rb @@ -104,18 +104,18 @@ class Complex < Numeric end alias_method :imag, :imaginary -end -[Fixnum, Float].each do |cls| - [:+, :-, :*, :/, :==].each do |op| - cls.instance_exec do - original_operator_name = "__original_operator_#{op}_complex" - alias_method original_operator_name, op - define_method op do |rhs| - if rhs.is_a? Complex - Complex(self).send(op, rhs) - else - send(original_operator_name, rhs) + [Fixnum, Float].each do |cls| + [:+, :-, :*, :/, :==].each do |op| + cls.instance_exec do + original_operator_name = "__original_operator_#{op}_complex" + alias_method original_operator_name, op + define_method op do |rhs| + if rhs.is_a? Complex + Complex(self).send(op, rhs) + else + send(original_operator_name, rhs) + end end end end |
