我是Ruby的新手,我正试图找出循环语法。
我有这个伪代码,但需要将其转换为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])
}
我目前有以下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