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 trialNikolaï POSNER
284 PointsMethodes dependancy
Hi, at the end of this video we are running two differents methodes: deposite & show balance.
I just don't understand why the methode "show balance" wait for the return of the methode "deposit". In my point of view we should have the balance as soon as we run the file. I guess it shouldn't but why ?
Many thanks to all, amazing platform!
Niko
3 Answers
David Curtis
11,301 Pointshi, if you will post the code, i will take a look and try to answer your question.
Timothy McCune
6,744 PointsIf i understand your question correctly, we do start off with a balance of 0. In the initialize method, there are 2 properties that are created: @transaction and @balance. Although this version of the file, doesn't use it, @transaction is created as an array. The second property @balance is set to 0.
If you change the @balance = 0 line, in the initialize method, to another value, the program will start of with a different balance. Each time you run the file, it will always start off with what ever balance the initialize method assigns to the @balance property.
I hope this answered your question
moseskisekka
5,316 PointsWasn't the question about the method "showbalance" waiting on return of method "deposit"?
Deposit is called first and it has to complete before showbalance can start - the methods are run in sequence. Deposit pauses to take input from the screen, so until it gets an input, it cannot return. Just like the ATM will wait for you to give input before anything else happens.