Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Numeric#to_int

num.to_int → integer

Invokes the child class’s to_i method to convert num to an integer.

Example
1.0.class          #=> Float
1.0.to_int.class   #=> Integer
1.0.to_i.class     #=> Integer
See also #to_c #truncate #step #zero? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1