Amokrane Chentir - 3 months ago 15

Ruby Question

Is there a keyword to express Infinity in Ruby?

Answer

**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}