Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?

variable_assignment.mm
float subtotal;
-(void)calculateTip:(subtotal*)subtotal{

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

1 Answer

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,258 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.