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 Swift Functions and Optionals Functions Creating a Function

Angelo Bustonera
Angelo Bustonera
554 Points

When calling a function with a parameter, would you need to specify the parameter as well or just () ? Thank You.

Sorry if the question seems trivial, I was just curious if you need to specify the parameter when calling a function with a parameter or is function name plus open and close parentheses enough?

1 Answer

Florian Bauernhofer
Florian Bauernhofer
12,809 Points

I am not sure if i understand you correctly, but:

If you call a function which needs a parameter, you of course have to give the function the parameter it need to work. Example: println() --> if you don't give the function a parameter it won't print anything to the console.

You just use function calls with open and close parentheses if the function does not require any parameters.

Angelo Bustonera
Angelo Bustonera
554 Points

Thank you, sir. I see now it was explained in the following video. Thanks again!