20. 'For' Shame! help needed!


#1

Let's finish up by refactoring the for loop on the right to use .times instead.

original:

for i in (1..3)
puts "I'm a refactoring master!"
end

my answer:

3.times do
puts "I'm a refactoring master!"
end

OR

3.times { puts "I'm a refactoring master!"}

I THINK i checked my spelling, just in case if there is some mistake that I missed. it's unintentional, and I didn't made the same mistake during the code practice!!! :slight_smile:

No matter how i tried, I can get the answer, but got stuck at that level, can someone shed some light on this please ?

Thank you


#2

What course are you learning?


#3

Hi @pammarie:

I was learning Ruby. got stuck at that puzzle at first.
and i accidentally figured out how to fix it. originally, I didn't delete the 'for' loop that was there by default, I just change it into comment by multi line comment options ( =begin ...... =end )
although technically it wouldn't affect the code, but after I deleted 'for' loop, it worked and let me go thru the puzzle.

Thank you for trying to help :slight_smile:


#4

Good to hear you were able to solve the lesson. :slight_smile::+1:


#5

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.