Github user jwagenleitner commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/403#discussion_r76540119
  
    --- Diff: src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java ---
    @@ -10563,13 +10563,21 @@ private void prepare() {
         /**
          * Coerce an object instance to a boolean value.
          * An object is coerced to true if it's not null, to false if it is 
null.
    +     * One exception to this is in the case of a non-null {@code 
java.util.Optional}
    +     * in which case the result of the {@code isPresent} method is 
returned.
          *
          * @param object the object to coerce
          * @return the boolean value
          * @since 1.7.0
          */
         public static boolean asBoolean(Object object) {
    -        return object != null;
    +        if (object == null) {
    +            return false;
    +        }
    +        if ("java.util.Optional".equals(object.getClass().getName())) {
    --- End diff --
    
    Good suggestion, I've added the todo comment.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to