Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialOsman Ercanli
3,579 Pointshelp with forloop syntax error
for item in ["Programming", "is", "fun"] puts "Item is #{item}." end
--for the code above I am getting the below error, I can't seem to find what to correct, thank you in advance for any help--
treehouse:~/workspace$ ruby forloop.rb
forloop.rb:1: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
for item in ["Programming", "is", "fun"]
^
forloop.rb:1: syntax error, unexpected ',', expecting end-of-input
for item in ["Programming", "is", "fun"]
2 Answers
Samuel Ferree
31,722 PointsYou're missing the do keyword, Try this
for item in ["Programming", "is", "fun"] do
puts item
end
Osman Ercanli
3,579 Pointsthank you so much Samuel
K .
2,357 PointsK .
2,357 PointsJason doesnt use the do keyword in the video though..