Skip to content
Related Articles

Related Articles

Ruby | Integer << function
  • Last Updated : 18 Dec, 2019

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:






# Ruby program for << method in Integer 
    
# Initialize numbers 
num1 = 6
num2 = 3 
  
# Prints <<
print num1 << num2


Output:

48

Example 2:




# Ruby program for << method in Integer 
    
# Initialize numbers 
num1 = 2
num2 = 2 
  
# Prints <<
print num1 << num2


Output:

8
My Personal Notes arrow_drop_up
Recommended Articles
Page :