Ruby - Loops and Iteration
Which of the following Ruby code snippets correctly uses an iterator to print each element of the array
arr?arr?each uses a block with a pipe-delimited parameter.arr.each { |element| puts element }. for element in arr puts element end uses a loop, not an iterator. arr.loop { |element| puts element } uses a non-existent method loop on array. arr.each do element puts element end misses the pipe delimiters in the block.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions