Closed samuelgoto closed 5 years ago
For example, it seems like we are deviating from the syntax in Swift/C#. I'm sure we have good reasons, but it would be great if we could list/enumerate the differences and have a short summary of the decisions/trade-offs that were made.
I've given a little more details in the explainer. C#, Swift and CoffeeScript have more or less the same semantics as this proposal. For Groovy and Ruby, I don’t know.
(Also, for Swift, the correct doc section is: Optional Chaining)
There are still missing details. For example, for Groovy and Ruby, I don’t know whether the equivalent of null?.b.c
resolves to null
or to null.c
.
If you know more details that are worth to be added, you may open an Issue or a PR.
Ruby doesn't do long short-circuiting, so it'll try doing null.c
(it's actually nil
, not null
).
@jridgewell Thank you. After many research, I have found a place where it is documented. As with Kotlin and Dart, that makes sense, because you can call methods on nil. Added in 8c9b6cb1f72a67156ee511378900005c3aa18967
(Maybe that one day, inspired by Ruby, we will introduce the indispensible ?.!= operator?)
It is great that this has so much precedence in other languages, makes everything so much simpler to look at: (a) it passes the test of time, (b) we get the benefit of hindsight, (c) we get the benefit of documentation/etc.
This list sounds like a pretty solid list [1], thanks for compiling.
Could you state explicitly (in the README file or somewhere else as an addendum) on which (if any) are the differences between your proposal and how things work in other languages (it would be great if the answer was "it doesn't, things are just the same" but when/if not, it is even more important to call that out explicitly and explain the rationale maybe with an example or two)?
[1]
Prior Art