End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Complex.rectangular
Complex.rect(real[, imag]) → complex
Complex.rectangular(real[, imag]) → complex
complex.c
View on GitHub ↗
static VALUE
nucomp_s_new(int argc, VALUE *argv, VALUE klass)
{
VALUE real, imag;
switch (rb_scan_args(argc, argv, "11", &real, &imag)) {
case 1:
real = nucomp_real_check(real);
imag = ZERO;
break;
default:
real = nucomp_real_check(real);
imag = nucomp_real_check(imag);
break;
}
return nucomp_s_new_internal(klass, real, imag);
}
Returns a complex object which denotes the given rectangular form.
Example
Complex.rectangular(1, 2) #=> (1+2i)