0

I'm getting bit confused hopefully somebody can put me straight

i have function which works as i would expect in the playground

    func testFunction(Astring:String,Anumber:Int,Afloat:CGFloat)
{
    println(Astring)
    println(Anumber)
    println(Afloat)   
}

 testFunction("Hello",25,25.00)

but in a project i have to call it like this, if i don't i get error missing argument label "Afloat:" in call

  testFunction("Hello",Anumber:25,Afloat:25.00)

the only difference is I'm calling the function from a button? thanks for the help of this site without it I would be lost

user2164327
  • 283
  • 1
  • 2
  • 13

1 Answers1

0

By default, parameters after the first parameter require you to use the external name. If you do not want an external name, then you have to define that in the function. Also as a style point, local variables should start with lower case. Regardless, this should get you what you want. The "_" character basically says no external name.

func testFunction(aString:String, _ aNumber:Int, _ aFloat:CGFloat)  
Jeremy Pope
  • 3,342
  • 1
  • 16
  • 17
  • hi thanks I've learnt something today cheers i like to call functions without external names keeps the code cleaner thanks for the style point I'm pretty bad at writing in general so my code is quite messy – user2164327 Feb 27 '15 at 08:13