Amazon.com Widgets Question about Exercise 8 (@implementation issue)
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2013, 09:36:34 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Answers to Exercises
| | |-+  Chapter 4
| | | |-+  Question about Exercise 8 (@implementation issue)
Pages: [1]   Go Down
Print
Author Topic: Question about Exercise 8 (@implementation issue)  (Read 345 times)
sugarboyloveOC
Newbie
*
Posts: 8






« on: September 10, 2011, 12:49:15 AM »

Dear Steve,

In my work, I write the (add:, subtract:, multiply:, and divide:) method is :


-(double) accumulator
{
    return accumulator;
}

-(double) add: (double) value
{
    return accumulator += value;
}

-(double) subtract: (double) value
{
    return accumulator -= value;
}

-(double) multiply: (double) value
{
    return accumulator *= value;
}

-(double) divide: (double) value
{
    return accumulator /= value;
}

ANd it is work.

But when I read the other post from other people, some people  write this :

-(double) divide: (double) value
{
    accumulator /= value;
    return accumulator;
}

I try it and it is work too. SO I want to know is there any difference between with

-(double) divide: (double) value
{
    return accumulator /= value;
}


and

-(double) divide: (double) value
{
    accumulator /= value;
    return accumulator;
}


?

Looking for your reply !!!
« Last Edit: September 10, 2011, 12:54:13 AM by sugarboyloveOC » Logged
fujilla
Global Moderator
Sr. Member
*****
Posts: 270


WWW




« Reply #1 on: September 10, 2011, 01:09:01 AM »

With
return accumulator /= value;
you are basically combining
accumulator /= value;
return accumulator;

into a single statement.

Nick
http://myfirstiphoneapp.co.uk
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.