You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2022/06/24 16:02:48 UTC
[GitHub] [groovy] eric-milles commented on pull request #1732: GROOVY-10223: support conversion of `Optional` to array/collection
eric-milles commented on PR #1732:
URL: https://github.com/apache/groovy/pull/1732#issuecomment-1165715088
You can also do this, but I don't think it is an improvement over "optional.map(String::length).orElse(null)" or "optional.orElse(null)?.length()":
```groovy
def nothing = Optional.empty(), something = Optional.of('foo')
def value = nothing*.length()?[0]
assert value == null
value = something*.length()?[0]
assert value == 3
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org