Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
Swift
/
Protocol constraints and existentials
Only `sortedValues()` compares a container’s elements. Where should `Element: Comparable`…
from Protocol constraints and existentials
Swift 6.3.3
intermediate
1 min
Only `sortedValues()` compares a container’s elements. Where should `Element: Comparable` usually go?
On `sortedValues()` or a constrained extension containing it.
On the entire container declaration in every case.
Nowhere; cast every element to Comparable at runtime.
On every caller that reads the container count.
Check
Ask AI about this kata
Report an error
previous kata
Which form fits a returned value whose implementation chooses one hidden concrete type?
Quiz
next kata
What does this program print?
Predict the output
A new version is available
Reload