Dwords = {"Ruby", "is", "fun"}
words.each do |word|
print word
end
Step-by-Step Solution
Solution:
Step 1: Identify correct array syntax
words = ["Ruby", "is", "fun"]
words.each { |word| puts word } uses square brackets [] to create an array, which is correct in Ruby.
Step 2: Check iteration and printing method
words = ["Ruby", "is", "fun"]
words.each { |word| puts word } uses each with a block and puts to print each word on a new line, which is the correct approach.
Final Answer:
words = ["Ruby", "is", "fun"]\nwords.each { |word| puts word } -> Option C
Quick Check:
Array + each + puts = print words line by line [OK]
Quick Trick:Use array.each with puts to print each item [OK]
Common Mistakes:
Using parentheses instead of brackets for arrays
Using print instead of puts for new lines
Using curly braces for arrays
Master "Basics and Runtime" in Ruby
9 interactive learning modes - each teaches the same concept differently