[swift-evolution] rename dropFirst() and dropLast()

Brent Royal-Gordon brent at architechies.com
Tue Dec 29 14:25:26 CST 2015


> I guess that's a good argument for keeping "prefix" and "suffix" instead of "take" and "takeEnd". But there is no good noun phrase to use for dropFirst/dropLast (Haskell's "init" and "tail" are nouns but they're very confusing and don't really make sense once you add in an integral argument anyway). The guidelines do say it's acceptable to use an imperative verb if there is no good noun phrase, so "skip" and "skipEnd" (or "skipLast", or maybe "skipSuffix" if we're keeping "suffix") are still reasonable.

I'm thinking:

	collection.onlyFirst(5)
	collection.exceptFirst(5)
	collection.onlyLast(5)
	collection.exceptLast(5)

Perfectly parallel, don't sound like mutating operations, and very clear about which part you keep and which part you toss.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list