Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Complex#real
real → numeric
complex.c
View on GitHub ↗
VALUE
rb_complex_real(VALUE self)
{
get_dat1(self);
return dat->real;
}
Returns the real value for self:
Example
Complex(7).real #=> 7 Complex(9, -4).real #=> 9
If self was created with polar coordinates, the returned value is computed, and may be inexact:
Example
Complex.polar(1, Math::PI/4).real # => 0.7071067811865476 # Square root of 2.