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!

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 Foundations Ruby Core Enumerable

Boris Baskovec
Boris Baskovec
4,798 Points

What 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?

Walter Ashbrook
Walter Ashbrook
8,848 Points

I am finding the same thing as well and would like to know why.

1 Answer

David Moore
David Moore
13,916 Points

You 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.