Ruby | Integer << function
Last Updated :
19 Mar, 2024
The << is an inbuilt method in Ruby returns the number which is shifted N times to the left. The resultant number is num * (2^N).
Syntax: num << N
Parameters: The function accepts no parameter.
Return Value: It returns num * (2^N).
Example 1:
num1 = 6
num2 = 3
print num1 << num2
|
Output:
48
Example 2:
num1 = 2
num2 = 2
print num1 << num2
|
Output:
8
Share your thoughts in the comments
Please Login to comment...