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 Function Error

I can't get a function with two parameters to work e.g.

func someFunction(firstParameterName: Int, secondParameterName: Int) { // function body goes here // firstParameterName and secondParameterName refer to // the argument values for the first and second parameters }

someFunction(1, 2)

THE ERROR RETURNED IS

Playground execution failed: /var/folders/yw/d3ntrqd13jl_xd_tkg3nm5p00000gq/T/./lldb/1036/playground13.swift:13:13: error: missing argument label 'secondParameterName:' in call someFunction(1,2) ^ secondParameterName:

NOTE:

I have version 7 of Xcode running on a macbook pro which is less than 6 months old.

thanks for your help

Kristian Egebæk-Carlsen
Kristian Egebæk-Carlsen
9,809 Points

Have you tried to call you function like this:

someFunction(firstParameterName: 1, secondParameterName, 2)

?

1 Answer

Hi Kristian Egebæk-Carlsen ... yes I tried that and it does not work? Thanks you for your thoughts.