iOS Object-Oriented Objective-C Diving Deeper - Classes, Properties and Methods Creating Methods!

how to specify method return type

How to specify return type as float?
float subtotal;

  [self.subtotal = self.subtotal * 0.2];
return float;

1 Answer

james south
james south
Front End Web Development Techdegree Graduate 33,250 Points

the return type goes where you have void. replace void with float. void methods operate by side-effect and do not return anything. instead of subtotal*, put float - that is the type of the argument given to the calculateTip method (edit - that may be acceptable, i'm just describing what worked for me to pass this challenge). in the body, use a new internal variable, like tip, and set it equal to subtotal * 0.2. finally, return tip. your last curly brace must come after the return statement, not before.