All of this highlights a significant tension between methods and functions in Swift.
The Object-Oriented paradigm is based around the concept of objects that encapsulate both state and behavior. However, in Swift, it’s simply impossible to implement certain generic functions as methods on the
Because of the constraint on the element of the sequence generator being
Equatable, this cannot be declared on a generic container, without thereby requiring elements in that collection to conform to
Relegating behavior like
partitionto top-level functions does a disservice to the standard library. Not only does it hide functionality from method autocompletion, but it fragments the API across a Object-Oriented and Functional paradigms.
Stay up-to-date by subscribing to the Comments RSS Feed for this post.