3 ms·
So interesting that a few years after Rust introduced the optional chaining operator, it's been filtered through the lens of many major languages out there. I
by leshow 7y ago
So interesting that a few years after Rust introduced the optional chaining operator, it's been filtered through the lens of many major languages out there.
I think Rust was the first to do it (if you don't count Haskell's more general do-notation). Can anyone confirm that?
- jsolson 7y agoSwift? Or, depending on how you feel about sending a message to nil simply returning nil, Objective-C? Swift's variant is much more modern, though, as it has the ability to inline assert. https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html https://docs.swift.org/swift-book/LanguageGuide/OptionalChai...
- leshow 7y agoRust had it before Swift did, I remember when the ? proposal came down the pipe to replace the try! macro and Swift didn't have it yet
- deleted 7y ago[deleted]
- rpeden 7y agoI think C# (and VB) had it before Rust. My memory of the timeline might be a bit off, though. I know C# and VB got the chaining operator in 2015.
- RubenSandwich 7y agoAfter some digging, I think Groovy got it first. Here is a blog post from 2009 about it: https://mrhaki.blogspot.com/2009/08/groovy-goodness-safe-navigation-to.html https://mrhaki.blogspot.com/2009/08/groovy-goodness-safe-nav....
- leshow 7y agoCool, thanks for this. Rust/Swift's variant is arguably a little different (because it works with a sum type) but I think the influence is pretty clear here.
- mchristen 7y agoCoffeescript has that operator.