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 trialBoris Baskovec
4,798 PointsWhat is @balance?
@balance is never used in the video (https://teamtreehouse.com/library/ruby-foundations/ruby-core/enumerable), balance is the method which returns a sum of all the operations in the transactions array, but the @balance is still 0 at the end, why is it even included?
1 Answer
David Moore
13,916 PointsYou are correct, it is not being used (so far as I can tell by skimming the vid). You could use @balance if you wanted to hold the current balance in a variable.
I should point out that while @balance and the method balance look alike (they have same name after all), they are in no way connected other than being part of the same class.
Walter Ashbrook
8,848 PointsWalter Ashbrook
8,848 PointsI am finding the same thing as well and would like to know why.