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 trial

iOS Objective-C Basics (Retired) Functional Programming in C Functions

functions

hi, I was just doing the test on functions and I don't understand what to put in the editor. I don't know what I'm doing wrong and because of hat I'm confused on it

1 Answer

hey daniel, not really familiar with Objective C but most languages are similar. Though it seems like it's asking for you to write a function named addTwo. It should look something liked this.. I will write out some pseudo(fake) code that would be used for strongly typed languages like objective C or java C++.

public double addTwo(double num1, double num2) {
            return double num1 + num2;    
}

If any of that doesn't make sense... Here is a good analogy a function is much like a CD player. You put a CD which is the parameter or argument into the CD player and the output is music your hear from the CD player. A function implementation of this would look something like..

public String CDPlayer(String cdYouWantToPlay) {
           String startMusic = "starting the music";

           return String cdYouWantToPlay + startMusic;

}

Now I can call that function or 'press play' on the function and it will return or 'give you back' the audio of the disk..

String metallicaCD = " Fade To Black"

CDPlayer(metallicaCD);

Hope this helps!