PROPOSAL: Elvis operator
jeremy.manson at gmail.com
Sat Mar 21 12:41:11 PDT 2009
On Sat, Mar 21, 2009 at 7:23 AM, Marek Kozieł <develop4lasu at gmail.com> wrote:
> 2009/3/21 Olivier Chorier <lapsus63 at gmail.com>
>> I initially thought it was a good idea, but after a bit reflection, I don't
>> think it is a real 'plus' compared with the ternary operator.
>> For example, how would you simplify those lines of code (assuming the coder
>> loves ternary operator) :
>> int value = object == null ? -1 :
>> (object.getSubObject() == null ? -1 :
>> (object.getSubObject().getValue() == null ? -1 :
>> Does somebody has an idea (excepting using an ugly try-catch statement) to
>> write this much clearer ?
>> (sorry for code indentation)
>> 2009/3/21 Stephen Colebourne <scolebourne at joda.org>
>> You wrong, this should look like:
> int value = object.?getSubObject().?getValue() ?: -1
It is worth pointing out that after strenuous objection, Stephen took
.? out of this proposal.
More information about the coin-dev