← Back to Upcase

Need help finding the bug here - Flash Card App


(Bert Mcguirk) #1

(George Brocklehurst) #2

There may be other bugs, but this line stood out to me:

@decks.detect { |deck| deck.name = name }

The single equal sign is for assignment, not comparison, so this line will change the name of the first deck it finds to the name you’re looking for, and then always return that deck.

It was tricky to follow some of the code because the formatting’s a bit off. If you repost the code to gist.github.com (or somewhere similar) and post a link here it’ll be easier to read.


(Bert Mcguirk) #3

Thanks george, that was the bug.