summaryrefslogtreecommitdiff
path: root/lib/complex.rb
diff options
context:
space:
mode:
authordave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-24 20:25:45 +0000
committerdave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-24 20:25:45 +0000
commitcaea614d4a6222c615fbb99710556f23f51711f8 (patch)
tree3ec41c8e5f4238d175673eaad7ff29a8b0d39f01 /lib/complex.rb
parent033ea1c46459c258f6b8854641cdeb84ed8edc30 (diff)
Re-expose Complex.new as .new! (Kernel#Complex needs to call _something_ :)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/complex.rb')
-rw-r--r--lib/complex.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/complex.rb b/lib/complex.rb
index 90916d125e..6b3e42f4e2 100644
--- a/lib/complex.rb
+++ b/lib/complex.rb
@@ -41,7 +41,7 @@ def Complex(a, b = 0)
elsif b == 0 and defined? Complex::Unify
a
else
- Complex.new(a, b)
+ Complex.new!(a, b)
end
end
@@ -70,7 +70,11 @@ class Complex < Numeric
#
# Creates a +Complex+ number <tt>a</tt>+<tt>b</tt><i>i</i>.
#
- def initialize(a, b = 0)
+ def Complex.new!(a, b=0)
+ new(a,b)
+ end
+
+ def initialize(a, b)
raise "non numeric 1st arg `#{a.inspect}'" if !a.kind_of? Numeric
raise "non numeric 2nd arg `#{b.inspect}'" if !b.kind_of? Numeric
@real = a
@@ -274,7 +278,7 @@ class Complex < Numeric
#
def coerce(other)
if Complex.generic?(other)
- return Complex.new(other), self
+ return Complex.new!(other), self
else
super
end
@@ -412,7 +416,7 @@ class Fixnum
# Redefined to handle a Complex argument.
def ** (other)
if self < 0
- Complex.new(self) ** other
+ Complex.new!(self, 0) ** other
else
if defined? Rational
if other >= 0