4 ms·
Cool story. I use Swift. It does not have default switch fallthrough. After a couple of versions, I learned about the fallthrough statement. I remember being
by ChrisMarshallNY 7y ago
Cool story.
I use Swift. It does not have default switch fallthrough. After a couple of versions, I learned about the fallthrough statement.
I remember being frustrated by it, at first, but, like so many Swift oddities, it rapidly became second nature; thus, proving out that one of the goals of Swift is to train developers to write code properly.
- saagarjha 7y agoI thought the first release of Swift had fallthrough?
- ChrisMarshallNY 7y agoMaybe it did, but I didn’t learn about it for quite some time. I just learned to work around it. Swift is a deep river. I still learn new stuff every day, and I write Swift, seven days a week.
- tcbasche 7y agoGo also has the same behaviour, with the fallthrough keyword. I find myself using a switch so rarely anyway...
- earthboundkid 7y agoGo has a fallthrough keyword, but you can also do case "a", "b": for simple things where two cases are the exact same.
- ChrisMarshallNY 7y agoSwift allows the same thing. In fact, Swift switch statements are powerful as all git-go. You can do things like specify ranges and whatnot. https://littlegreenviper.com/miscellany/swiftwater/ranges-and-sequences/#switchranges https://littlegreenviper.com/miscellany/swiftwater/ranges-an... https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID129 https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.... That said, I don't use them that often. They tend to take up a lot of real estate on the screen, and introduce a fair bit of CC.