I've ended up using Swift without autocomplete recently and noticed I keep mistyping the method dropFirst() on Sequence types. Is there a reason this isn't named 'droppingFirst()' as might be suggested by this section of the API design guidelines?
Just looking at the API guidelines I understand dropFirst() to be a mutating method and that is why the 'ed' or 'ing' suffix is not added to make it droppingFirst(). In that dropFirst returns a mutated value. Someone please correct me if I am wrong here.
Hi Matt. 'Mutating' is typically used to mean that the method mutates the object that it is called on. i.e. if dropFirst were mutating we would expect it to remove the first element from the sequence that it is called on.
dropFirst() is non-mutating and we can quickly verify that in the REPL:
Thank you, Jared_Khan. I would have understood that method to mutate the original object then based upon the name of dropFirst(). Thus making the point in which you are bringing up in this post.
Yeah. Naming could be better, should be mapping, filtering, etc. I seem to remember that drop, map, etc. we’re declared ‘state-of-the-art’ terms and therefore used instead of the more logical version.