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 trial

Ruby Ruby Foundations Loops Control Flow

James Nelson
James Nelson
23,956 Points

retry if

I am watching along Jason's Ruby Foundations, control flow video.

I have a loop the following loop -

animals = %w(dog cat horse goat snake frog) count = 0

for animal in animals puts "The current animal is #{animal}" break if count == 10 count += 1 retry if animal == 'horse' end

When I try to run this I get a SyntaxError on the retry if line. I have compared with Jason's code and it appears to be the exact same. Could someone spot the problem?


2 Answers

James Nelson
James Nelson
23,956 Points

Yeah I see this Jason, must be something to do with an updated version or Ruby. Thanks for you're reply