mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-compar-ext/compar.rb: Comparable#clamp to accept nil as arguments
This commit is contained in:
@@ -53,8 +53,17 @@ module Comparable
|
||||
if min.nil?
|
||||
min = self
|
||||
end
|
||||
elsif min.nil? or min < self
|
||||
return self
|
||||
else
|
||||
raise TypeError, "wrong argument type #{min.class}"
|
||||
return min
|
||||
end
|
||||
end
|
||||
if min.nil?
|
||||
if self < max
|
||||
return self
|
||||
else
|
||||
return max
|
||||
end
|
||||
end
|
||||
c = min <=> max
|
||||
|
||||
Reference in New Issue
Block a user