by kbsletten · 7y ago · 0 comments
https://therealdanvega.com/blog/2013/08/20/groovys-null-safe...
Not sure if that's in Rust, Kotlin, C#, or Ruby, or in Groovy's Antlr 4 parser.
That is, in Rust you'd use Option::map or Option::and_then, there is no equivalent to the `?.` and `?[]` operators, the `?` operator (or `try!` macro) is a shortcut for an "unwrapping guard".
x = [ foo: [ bar: 1] ]
x.foo.bar // 1
x.boo?.bar // null because x.boo is null
x.boo?.bar = 1 // succeeds even though x.boo is null
x.boo // still nullPatents protect how you something, not what you do.