Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm learning ruby on rails.
what are some common scenarios to use ** operator?


What I have tried:

I'm working through a tutorial ,and it is mentioned that during initilization we can use **operator , of a class. I'm want to know how to use this.
Posted
Updated 30-Mar-20 20:19pm
Comments
CPallini 31-Mar-20 2:18am    
It is documented as 'Exponent'. possibly you should report some context, here.

1 solution

The ** operator just returns X to the power of Y:
X ** Y
2 ** 2 = 4
2 ** 3 = 8
10** 2 = 100
So the only place you use it is ... when you want a number raised to a power: the square for example, or the cube.
 
Share this answer
 
Comments
yebaha 31-Mar-20 9:08am    
I was talking about double splat operator in ruby
OriginalGriff 31-Mar-20 9:13am    
Yes I know. So was I ... and it's called "star" or "asterisk", not "splat".
https://www.tutorialspoint.com/ruby/ruby_operators.htm
Richard Deeming 1-Apr-20 13:56pm    
The splat and double splat operators are different beasts though:
Splat goes Ruby - Relatel Developers Blog[^]
Drat! - Ruby has a Double Splat - Relatel Developers Blog[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900