Pick the fix
A function always returns one Shape type, and callers should get static dispatch. Which return type?
Hint 1 of 1
Who chooses the concrete type?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A -> some Shape
Correct. One hidden concrete type with no boxing.
Why not the others?
- B
-> any Shape. It works but boxes the value and uses dynamic dispatch without need. - C
-> Shape. Swift 6 requiresanyfor an existential, and that would box anyway. - D
func make<T: Shape>() -> T. Here the caller picks T, but this function wants to pick the type itself.