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
This commit is contained in:
parent
033ea1c464
commit
caea614d4a
@ -1,4 +1,7 @@
|
|||||||
2003-04-24 Dave Thomas <dave@wireless_1.local.thomases.com>
|
2003-04-24 Dave Thomas <dave@thomases.com>
|
||||||
|
|
||||||
|
* lib/complex.rb (new!): Complex.new had been made private, but
|
||||||
|
Kernel#Complex called it. Re-exposed as new!.
|
||||||
|
|
||||||
* lib/matrix.rb (Matrix.row_vector): Fix method name typo
|
* lib/matrix.rb (Matrix.row_vector): Fix method name typo
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ def Complex(a, b = 0)
|
|||||||
elsif b == 0 and defined? Complex::Unify
|
elsif b == 0 and defined? Complex::Unify
|
||||||
a
|
a
|
||||||
else
|
else
|
||||||
Complex.new(a, b)
|
Complex.new!(a, b)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -70,7 +70,11 @@ class Complex < Numeric
|
|||||||
#
|
#
|
||||||
# Creates a +Complex+ number <tt>a</tt>+<tt>b</tt><i>i</i>.
|
# 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 1st arg `#{a.inspect}'" if !a.kind_of? Numeric
|
||||||
raise "non numeric 2nd arg `#{b.inspect}'" if !b.kind_of? Numeric
|
raise "non numeric 2nd arg `#{b.inspect}'" if !b.kind_of? Numeric
|
||||||
@real = a
|
@real = a
|
||||||
@ -274,7 +278,7 @@ class Complex < Numeric
|
|||||||
#
|
#
|
||||||
def coerce(other)
|
def coerce(other)
|
||||||
if Complex.generic?(other)
|
if Complex.generic?(other)
|
||||||
return Complex.new(other), self
|
return Complex.new!(other), self
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@ -412,7 +416,7 @@ class Fixnum
|
|||||||
# Redefined to handle a Complex argument.
|
# Redefined to handle a Complex argument.
|
||||||
def ** (other)
|
def ** (other)
|
||||||
if self < 0
|
if self < 0
|
||||||
Complex.new(self) ** other
|
Complex.new!(self, 0) ** other
|
||||||
else
|
else
|
||||||
if defined? Rational
|
if defined? Rational
|
||||||
if other >= 0
|
if other >= 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user