Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Complex#inspect

() -> ::String
inspect → string

Returns a string representation of self:

Example
Complex.rect(2).inspect                      # => "(2+0i)"
Complex.rect(-8, 6).inspect                  # => "(-8+6i)"
Complex.rect(0, Rational(1, 2)).inspect      # => "(0+(1/2)*i)"
Complex.rect(0, Float::INFINITY).inspect     # => "(0+Infinity*i)"
Complex.rect(Float::NAN, Float::NAN).inspect # => "(NaN+NaN*i)"
See also #infinite? #magnitude #imaginary #numerator also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0