Swift 6 · Types and protocols
Generics
Write a function once for any type that meets a constraint.
func largest<T: Comparable>(_ items: [T]) -> T? {
items.max()
}
Official Swift 6 documentation
Swift 6 · Types and protocols
Write a function once for any type that meets a constraint.
func largest<T: Comparable>(_ items: [T]) -> T? {
items.max()
}
Official Swift 6 documentation
Was this page helpful?