Project

General

Profile

Misc #15654

Documentation for Complex is wrong or misleading

Added by sawa (Tsuyoshi Sawada) 4 months ago. Updated 4 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
[ruby-core:91766]

Description

The documentation for Complex https://ruby-doc.org/core-2.6/Complex.html says or implies that a complex can be created by literal like 2+1i, but that is actually calling the method + on receiver 2 with argument 1i. The description should be changed to make it clear that 2+ 1i is not a literal but is applying a method.

History

Updated by Hanmac (Hans Mackowiak) 4 months ago

nobu (Nobuyoshi Nakada): i don't know if that would be better, but can the parser be changed to support that stuff like "2+1i" would create the Complex object directly?

Updated by sawa (Tsuyoshi Sawada) 4 months ago

Actually, currently, there is no literal for complex numbers whose real part is non-zero. I think we need a literal to cover such cases. If something along nobu's suggestion works, that would be preferable.

Updated by Hanmac (Hans Mackowiak) 4 months ago

sawa (Tsuyoshi Sawada) wrote:

Actually, currently, there is no literal for complex numbers whose real part is non-zero. I think we need a literal to cover such cases. If something along nobu's suggestion works, that would be preferable.

it wasn't a suggestion from him, i just wanted to ping him so he can see the message

Updated by nobu (Nobuyoshi Nakada) 4 months ago

There would be a chance to optimize such expressions, but it is not a single literal syntactically, and constant folding is disabled in Ruby for its dynamic nature.
New literal syntax will be needed for an (impurely) imaginary number literal, but I doubt that we really need it.

Also available in: Atom PDF