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 Loops Ruby Loops The Ruby Loop

Leonardo Cavalcanti
Leonardo Cavalcanti
5,308 Points

loop doesnt work, first ruby loop assignment quiz

numbers = [] variable=0 loop numbers+=[1] variable=numbers.length if variable==3 break end end number = 0

write your loop here

Not sure why im getting this error

rb:9: syntax error, unexpected keyword_end, expecting end-of-input

waiting for some help.

loop.rb
numbers = []
variable=0
loop
  numbers+=[1]
  variable=numbers.length
  if variable==3
  break
  end
end
number = 0

# write your loop here

1 Answer

You need to either use the do and end keywords or use curly braces around your block; in your case, you are missing the do after loop on line 3.

Leonardo Cavalcanti
Leonardo Cavalcanti
5,308 Points

Yeah, simple mistake, sorry for taking your time but i was struggling and couldnt find anything wrong... pretty dumb of me eh

When you stare at something long enough, it gets hard to see even "simple mistakes." An extra set of eyes always helps!