>
> My personal opinion on this is that 5.times { stuff} offers no benefits over
> “repeat 5 { stuff }”, so I’d rather see the later (if anything).
>
> This is all shades of gray with no clear answer. We generally want to have
> standard APIs pay for themselves and avoid confusion. I agree with DaveA’s
> points upthread. If you contrast it with forEach, forEach (barely!) pays for
> itself by allowing things like:
>
> collection.forEach(curriedMethod)
>
> That benefit doesn’t translate to “.times".
>
> -Chris
Thanks for weighing in!
The benefit of `5.times` vs `repeat 5` is that the former is (and can easily
be) defined in Swift, not as a language-level feature. OTOH `repeat 5` is a bit
more useful because it allows returning/breaking/etc.
But I also understand the argument that this feature isn’t worth it at all.
(There’s already a lot of libraries extending stdlib with things of this sort!)
— Radek
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution