title: objective-c: return value
body: <p>I'm reading Stephen Kochan's "Programming in Objective-C" (I'm n0000b). Everything has been obvious to me until exercise 4-8.</p>
  
  <p>It asks me to modify methods, in an "Accumulator" class created earlier in the chapter, to "return" the value of the accumulator when one of the math methods is used (basically it's a calculator). I took this originally to mean that I want the program to display the result whenever one of the methods is used (+, -, *, /), so I set it up to do so, so each line displays the cumulative result rather than just the final result:</p>
  
  <pre><code>[deskCalc setAccumulator: 0.0];
  [deskCalc add: 200.]; //the result is displayed
  [deskCalc divide: 100.0]; //the result is displayed
  [deskCalc subtract: 1.0]; //the result is displayed
  [deskCalc multiply: 5]; //the result is displayed
  NSLog (@"The result is %g", [deskCalc accumulator]);
  </code></pre>
  
  <p>But after looking up other people's solutions, it appears that "returning the value of the Accumulator" means something different. </p>
  
  <p>Can someone describe to me what returning a value means, and what purpose it serves? I have looked through the previous chapter a few times but it is still unclear to me how this will make the program behave differently.</p>
  
  <p>Thanks!
  -Andrew</p>