Bird
0
0

Which of the following is the correct way to declare a function with an argument label from and a parameter name start of type Int?

easy📝 Syntax Q12 of 15
Swift - Functions
Which of the following is the correct way to declare a function with an argument label from and a parameter name start of type Int?
Afunc move(from: start Int) { }
Bfunc move(from start: Int) { }
Cfunc move(start from: Int) { }
Dfunc move(Int from start) { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall Swift function syntax for labels

    The syntax is: func name(argumentLabel parameterName: Type) { }.
  2. Step 2: Match the syntax with given options

    func move(from start: Int) { } matches this syntax exactly: func move(from start: Int) { }.
  3. Final Answer:

    func move(from start: Int) { } -> Option B
  4. Quick Check:

    Argument label before parameter name [OK]
Quick Trick: Argument label comes before parameter name in declaration [OK]
Common Mistakes:
  • Swapping argument label and parameter name order
  • Putting type before parameter name
  • Using invalid syntax with colons misplaced

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes