我正在尝试使用以下代码从负数的平方根创建一个复数:
include Math
z = Complex(sqrt(-9))
但它会产生这个错误:
Math::DomainError: Numerical argument is out of domain - "sqrt"
from kata2.rb:20:in `sqrt'
from kata2.rb:20:in `polinomio'
from kata2.rb:34
from /home/howarto/.rvm/rubies/ruby-2.0.0-p247/bin/irb:13:in `<main>'
如何从负数的平方根构建复数?