create an array of string in Ruby
Code snippet on how to create an array of string in Ruby
my_array = ["string1", "string2", "string3"]
This code creates an array of strings in Ruby. First, the name of the array is defined as “my_array”. Then within the brackets, three strings are included, “string1”, “string2”, and “string3”. The individual strings are separated by commas, which creates an array of three elements. Array elements are accessed by their index position beginning with 0, so “string1” would be at index 0, “string2” at index 1, etc. This is a useful way to store related pieces of data in one easily accessible place.