Ruby arithmetic question

Dear all,

I am very new to ruby language. I have some question in Ruby arthmetic
operation.

Why did i get 2 ** 2 = 4 ??

a = 2 ** 2

puts a

–> 4
Why ?

It is like 2 ^ 2 = 4 ???

regards,
salai.

quoth the Salai K.:

Dear all,

I am very new to ruby language. I have some question in Ruby arthmetic
operation.

Why did i get 2 ** 2 = 4 ??

Because ‘**’ is the exponentiation operator.

a = 2 ** 2

puts a

–> 4
Why ?

It is like 2 ^ 2 = 4 ???

Exactly…

regards,
salai.

-d

Salai,

welcome to Ruby!
You’re right - 2**2 is 2 to the power of 2.

Best regards,

Axel

-------- Original-Nachricht --------
Datum: Sun, 17 Jun 2007 00:02:16 +0900
Von: “Salai K.” [email protected]
An: [email protected]
Betreff: Ruby arithmetic question.