Bird
0
0

Given this function:

hard📝 Application Q9 of 15
Swift - Functions
Given this function:
func configure(button title: String, color: String) {
    print("Button titled \(title) with color \(color) configured.")
}

Which call will cause a compile-time error?
Aconfigure(button: "Submit", color: "Red")
Bconfigure(button: "Submit", color: "Blue")
Cconfigure(title: "Submit", color: "Blue")
Dconfigure(button: "Cancel", color: "Green")
Step-by-Step Solution
Solution:
  1. Step 1: Identify argument labels in function declaration

    The first parameter has argument label button, second parameter color.
  2. Step 2: Check each call for correct argument labels

    configure(title: "Submit", color: "Blue") uses title instead of button, causing a compile-time error.
  3. Final Answer:

    configure(title: "Submit", color: "Blue") -> Option C
  4. Quick Check:

    Use declared argument labels exactly [OK]
Quick Trick: Call functions with exact argument labels declared [OK]
Common Mistakes:
  • Using parameter names instead of argument labels
  • Swapping argument labels
  • Omitting argument labels when required

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes