Hi,

2013/8/27 Nokan Emiro <uzleepito / gmail.com>:
> Hi,
>
> could someone please explain me what the hack is happening here?
>
> $ irb
> irb(main):001:0> 2.718281828459045
> => 2.718281828459045
> irb(main):002:0> Math.tan(2.718281828459045)
> => -0.4505495340698077
> irb(main):003:0> -0.4505495340698077 ** 2.718281828459045
> => -0.11449187080996949
> irb(main):004:0> Math.tan(2.718281828459045) ** 2.718281828459045
> => (-0.07250262422001937+0.08861014593587692i)
> irb(main):005:0>
>
It is due to the Ruby operator precedence.
http://www.techotopia.com/index.php/Ruby_Operator_Precedence#Operator_Precedence_Table

irb(main):001:0>  -0.4505495340698077 ** 2.718281828459045
=> -0.11449187080996949
irb(main):002:0>  (-0.4505495340698077) ** 2.718281828459045
=> (-0.07250262422001937+0.08861014593587692i)

>
> How comes that Complex value here?  (Well, require "complex" isn't mentioned
> anywhere and it's not an accident. This is a virgin irb session, the Complex
> lib isn't loaded.)
>
> When I type _.class as the next line, I get Complex.  But Complex isn't
> loaded
> at all.  If I type in require 'complex', I get the answer: true.  That
> means, the
> Complex class was just loaded, right after the things happening above.
>
> u.
>

Regards,
Park Heesob