Skip to content

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

instance method

Complex#arg

arg → float

Returns the argument (angle) for self in radians; see polar coordinates:

Example
Complex.polar(3, Math::PI/2).arg  # => 1.57079632679489660

If self was created with rectangular coordinates, the returned value is computed, and may be inexact:

Example
Complex.polar(1, 1.0/3).arg # => 0.33333333333333326
See also #angle #as_json #abs2 #conj also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0