I'm new to Ruby and am trying to figure out the looping syntax.
I have this pseudocode but need to convert it to Ruby
# array
search = ["fallacy", "epitome"]
for (i = 0, i > search.length, i++) {
# Get back the result for each search element
response[i] = Word.get_definition(search[i])
}
I currently have the following Ruby
# create empty response array
response = []
search.each do |element, index|
# Get back the result for each search element
response(index) = Word.get_definition(element(index))
end
search.index(element)but @limelights solution seems to fit your needs.