In role Real§

See primary documentation in context for method Complex

method Complex(Real:D: --> Complex:D)

Converts the number to a Complex with the number converted to a Num as its real part and 0e0 as the imaginary part.

In ComplexStr§

See primary documentation in context for method Complex

method Complex

Returns the Complex value of the ComplexStr.

In Cool§

See primary documentation in context for method Complex

multi method Complex()

Coerces the invocant to a Numeric and calls its .Complex method. Fails if the coercion to a Numeric cannot be done.

say 1+1i.Complex;         # OUTPUT: «1+1i␤» 
say π.Complex;            # OUTPUT: «3.141592653589793+0i␤» 
say <1.3>.Complex;        # OUTPUT: «1.3+0i␤» 
say (-4/3).Complex;       # OUTPUT: «-1.3333333333333333+0i␤» 
say "foo".Complex.^name;  # OUTPUT: «Failure␤»