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 trialJulian Gu
12,490 PointsShouldn't you change the currentSelection to nil after hitting the purchase button?
If this is not done, then even though the visual representation indicates that nothing is selected, the currentSelection variable is still holding the value of whatever is last selected. What this does is that you can keep hitting purchase and the vend method will keep being executed.
Kareem Jeiroudi
14,984 PointsThat's absolutely right! I think we should, because if you click 'purchase' again, it'll purchase the same item although it hasn't been selected. However, I haven't implemented it yet. If you have, let me know about how you've done it.
1 Answer
Thomas Dobson
7,511 PointsYou have the right idea and have are correct about this bug. The solution I am afraid is not that simple. I wasn't able to get it to work correctly.
Joshua Hardy
17,317 PointsJoshua Hardy
17,317 PointsDo you have any code or a program to go along with this question?