How to express infinity in Ruby?
问题 Is there a keyword to express Infinity in Ruby? 回答1: If you use ruby 1.9.2, you can use : >> Float::INFINITY #=> Infinity >> 3 < Float::INFINITY #=> true Or you can create your own constant using the following*: I've checked that in Ruby 1.8.6, 1.8.7, and 1.9.2 you have Float.infinite?. PositiveInfinity = +1.0/0.0 => Infinity NegativeInfinity = -1.0/0.0 => -Infinity CompleteInfinity = NegativeInfinity..PositiveInfinity => -Infinity..Infinity *I've verified this in Ruby 1.8.6 and 1.9.2 回答2: No