Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
Description
With Java 8 and the rising popularity of Optional type in lieu of null management, it would be great if Groovy's elvis could handle Optional in the same way.
Optional<String> string1 = Optional.of("foo") Optional<String> string2 = Optional.empty() assert "foo" == ( string1 ?: "bar" ) assert "bar" == ( string2 ?: "bar" )
Conversely, another option is to make elvis overloadable. ( something like orElse() ).
That way, other Option/al types ( i.e. from Guava or FJ ) can have extension methods to support their use as well.
Attachments
Issue Links
- relates to
-
GROOVY-7611 java.util.Optional should evaluate to false if empty
- Closed