Project

General

Profile

Actions

Bug #19004

closed

Complex can be nested by Complex.polar

Added by msnm (Masahiro Nomoto) about 2 years ago. Updated about 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:109879]

Description

Complex.polar with one argument can return a "nested" Complex instance, whose real part is also a Complex one.

puts RUBY_DESCRIPTION
# ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

p Complex.polar(1+0i)
# ((1+0i)+0i)

p 5.times.inject(1) { |num, _| Complex.polar(num) }
# (((((1+0i)+0i)+0i)+0i)+0i)

In Ruby < 2.7 , it simply raises an error when the argument is an instance of Complex (i.e. obj.real? == false).

puts RUBY_DESCRIPTION
# ruby 2.6.10p210 (2022-04-12 revision 67958) [x86_64-linux]

p Complex.polar(1+0i)
# TypeError (not a real)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0