Ruby | Integer << function
Last Updated :
19 Mar, 2024
Improve
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).
Ruby
Output:
Ruby
Output:
Syntax: num << N Parameters: The function accepts no parameter. Return Value: It returns num * (2^N).Example 1:
# Ruby program for << method in Integer
# Initialize numbers
num1 = 6
num2 = 3
# Prints <<
print num1 << num2
48Example 2:
# Ruby program for << method in Integer
# Initialize numbers
num1 = 2
num2 = 2
# Prints <<
print num1 << num2
8