[swift-evolution] removeFirst, optional equiviliant
jordan_rose at apple.com
Wed Jan 6 17:36:33 CST 2016
Hi, James. I'm having trouble thinking of when I want to remove something from an array unless the array is empty. The one case I can think of is when an array is being treated as a stack or queue and you're popping in a loop, but I (personally) rather write that with an explicit isEmpty check anyway. (It's not like it's any more or less efficient.)
Is there another scenario that I'm missing where this would be useful?
> On Jan 6, 2016, at 9:36, James Campbell via swift-evolution <swift-evolution at swift.org> wrote:
> If you call removeFirst and the array is empty it would be great if it was optional so it could return nil or at least it threw an error so you could handle that case.
> james at supmenow.com <mailto:james at supmenow.com>
> +44 7523 279 698
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution