Skip to content

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

instance method

Rational#inspect

rat.inspect → string

Returns the value as a string for inspection.

Example
Rational(2).inspect      #=> "(2/1)"
Rational(-8, 6).inspect  #=> "(-4/3)"
Rational('1/2').inspect  #=> "(1/2)"
See also #hash #magnitude #floor #negative? also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0