Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby nth element of array

# Ruby program to demonstrate the  
# accessing the elements of the array 
    
# creating string using [] 
str = ["GFG", "G4G", "Sudo", "Geeks"] 
    
# accessing array elements 
# using index 
puts str[1] 
    
# using the negative index 
puts str[-1]
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #ruby #nth #element #array
ADD COMMENT
Topic
Name
9+6 =