News for hackers. Stuff that matters.
Re:My Favourite Diff by ChrisMarshallNY on Sunday April 05, 2020 @06:50PM (#22789394)
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.

Re:My Favourite Diff by tcbasche on Monday April 06, 2020 @01:31AM (#22791128)
Go also has the same behaviour, with the fallthrough keyword. I find myself using a switch so rarely anyway...
Re:My Favourite Diff by earthboundkid on Monday April 06, 2020 @09:59AM (#22793740)
Go has a fallthrough keyword, but you can also do case "a", "b": for simple things where two cases are the exact same.
Re:My Favourite Diff by ChrisMarshallNY on Monday April 06, 2020 @11:49AM (#22794747)
Swift 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-an...

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.

Re:My Favourite Diff by saagarjha on Sunday April 05, 2020 @07:07PM (#22789496)
I thought the first release of Swift had fallthrough?
Re:My Favourite Diff by ChrisMarshallNY on Sunday April 05, 2020 @07:33PM (#22789636)
Maybe 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.