Ruby Array contains method index() to get the selected element index inside array. Syntax: Example: # array declaration lang = ["Java","Flutter","ReactNative","Ruby","Perl"] puts "Array index implementation." puts "Enter the element whose index you want to find:" ele = gets.chomp if(ind = lang.index(ele)) puts "#{ele} found at index #{ind}" else puts "Array doesn't contains given element" end Output
array_instance.index()
Array index implementation.
Enter the element whose index you want to find:
Flutter
Flutter found at index 1
Ruby program to check whether the given number is Armstrong
How to create two dimensional array in ruby?
What's the difference between a lambda, a block and a proc?
How to add/remove elements to Array in Ruby?
Ruby program to generate random numbers
How to Get Input with Gets in Ruby
How to Replace array elements in Ruby?
What are the various Ruby runtimes, and how are they different?
how to create an array with Array.[](*args) in Ruby ?
Ruby program to check whether the given number is palindrome
What are #method_missing and #send? Why are they useful?
Ruby program to print an array
Creating Array with Array.new(size, obj) in Ruby
Program to Print Triangle of Numbers in Ruby
Ruby program to add two integer numbers
What are some of your favorite gems? What are their alternatives?
How to get index of array element in Ruby
Ruby program to reverse a string
How to shuffle an array in Ruby?
How to Sort Array in Ruby?
Ruby program to check whether the given number is prime or not
Ruby program to Calculate the factorial of given number
Ruby program to print Fibonacci series