Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Integer#inspect

inspect(*args)

Alias of #to_s

Returns a string containing the place-value representation of self in radix base (in 2..36).

Example
12345.to_s               # => "12345"
12345.to_s(2)            # => "11000000111001"
12345.to_s(8)            # => "30071"
12345.to_s(10)           # => "12345"
12345.to_s(16)           # => "3039"
12345.to_s(36)           # => "9ix"
78546939656932.to_s(36)  # => "rubyrules"

Raises an exception if base is out of range.

See also #to_s #gcdlcm #integer? #gcd also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0