Skip to content
instance method

Complex#to_s

() -> ::String
to_s → string

Returns a string representation of self:

Example
Complex.rect(2).to_s                      # => "2+0i"
Complex.rect(-8, 6).to_s                  # => "-8+6i"
Complex.rect(0, Rational(1, 2)).to_s      # => "0+1/2i"
Complex.rect(0, Float::INFINITY).to_s     # => "0+Infinity*i"
Complex.rect(Float::NAN, Float::NAN).to_s # => "NaN+NaN*i"
See also #to_r #to_json also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0