|
|
|
|
|
by prophetjohn
4162 days ago
|
|
I haven't used Groovy much, so I may be completely missing something here, but how is the elvis operator different from a simple guard in Ruby? Based on the docs for elvis, it looks like potentiallyFalsyValue ?: safeDefault
is exactly equivalent to potentially_falsy_value || safe_default
in RubyFurther, the null-safe operator seems to be the same as #try in Rails and overuse of either is probably a bit of a smell that you might be violating Tell Don't Ask |
|
If || is used more frequently as a logical operator returning true(1) or false(0) to test logical or (not to be used for assignment), why overload this operator?
Having a separate operator like ?: better shows the intention of the usage. It also resembles the ternary function which has similar functionality.