> On 13 Oct 2016, at 16:19, Nevin Brackett-Rozinsky via swift-evolution > <[email protected]> wrote: > > If I might be so bold, perhaps we should consider the opposite. Suppose you > have a conditional statement inside a loop. It would be easier for the reader > to understand what it does if “break” meant the same thing regardless of > whether you used “if” or “switch” for the condition. > > Right now, these two loops behave differently: > > let seq = [1, 2, 3] > > for x in seq { // prints ! 2 ! 3 ! > switch x { > case 1: break > case _: print(x) > } > print("!") > } > > for x in seq { // prints nothing > if x == 1 { > break > } else { > print(x) > } > print("!") > } > > In particular, the current behavior of “break” means you need to label the > loop if you want to break out of it from a “switch”, but not from an “if”. > This is at least inconsistent. > > Nevin
That's an interesting point, but seems like it might be better covered by using a different keyword; e.g- we could use "end" for a loop and "break" for a switch? "End" feels more consistent with "continue", but we get into the pesky "terms of art" territory =) I don't think that requiring use of () is the right solution though, as it is admittedly kind of strange, I just seem to have picked up it in one tutorial and then never stopped using it =D _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
