Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby array shift

# Syntax: Array.shift()
# Parameter: Array
# REMOVES the first element of self and RETURNS it or nil if the array is empty.

a = [18, 22, 33, nil, 5, 6]
b = [1, 4, 1, 1, 88, 9]
c = [18, 22, 50, 6]
  
# shift method example
puts "shift() method form : #{a.shift()}
"  
puts "shift() method form : #{b.shift(2)}
"
puts "shift() method form : #{c.shift(3)}
"
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #ruby #array #shift
ADD COMMENT
Topic
Name
6+3 =