diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-15 16:45:03 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-15 16:45:03 +0000 |
| commit | f232bdfbe0d14a7dc5a838601b1a3b4d880d52d5 (patch) | |
| tree | 19afa15048b4c73f2a701a9b1ebf09a8c82ef203 /lib | |
| parent | 81a6adebf9c8c33ad697da0425db8570775cd985 (diff) | |
| download | ruby-f232bdfbe0d14a7dc5a838601b1a3b4d880d52d5.tar.gz ruby-f232bdfbe0d14a7dc5a838601b1a3b4d880d52d5.tar.xz ruby-f232bdfbe0d14a7dc5a838601b1a3b4d880d52d5.zip | |
* array.c (rb_ary_update): pedantic check to detect
rb_ary_to_ary() to modify the receiver. [ruby-dev:24861]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rational.rb | 24 | ||||
| -rw-r--r-- | lib/tempfile.rb | 2 |
2 files changed, 14 insertions, 12 deletions
diff --git a/lib/rational.rb b/lib/rational.rb index 2019363ac..224100485 100644 --- a/lib/rational.rb +++ b/lib/rational.rb @@ -312,20 +312,22 @@ class Integer return a end - def lcm(int) - a = self.abs - b = int.abs - gcd = a.gcd(b) - (a.div(gcd)) * b + def lcm(other) + if self.zero? or other.zero? + 0 + else + (self.div(self.gcd(other)) * other).abs + end end - def gcdlcm(int) - a = self.abs - b = int.abs - gcd = a.gcd(b) - return gcd, (a.div(gcd)) * b + def gcdlcm(other) + gcd = self.gcd(other) + if self.zero? or other.zero? + [gcd, 0] + else + [gcd, (self.div(gcd) * other).abs] + end end - end class Fixnum diff --git a/lib/tempfile.rb b/lib/tempfile.rb index 828e1cf8f..65b4bc69a 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -144,7 +144,7 @@ class Tempfile < DelegateClass(File) class << self def callback(data) # :nodoc: pid = $$ - lambda{ + Proc.new { if pid == $$ path, tmpfile, cleanlist = *data |
