You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/12/05 01:58:00 UTC

[jira] [Commented] (GROOVY-9848) Allow membership operator to work on maps

    [ https://issues.apache.org/jira/browse/GROOVY-9848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17244376#comment-17244376 ] 

Paul King commented on GROOVY-9848:
-----------------------------------

The membership operator "works" on maps but possibly not in the expected way. The `in` operator maps to `isCase` which is geared up for somewhat intuitive operation as part of a switch statement but effectively being member of keyset when used directly:
{code}
def map = [a: 1, b: 2]
assert 'a' in map     // key
assert 2 !in map     // value
assert [a: 1].iterator()[0] !in map   // entry
{code}

> Allow membership operator to work on maps
> -----------------------------------------
>
>                 Key: GROOVY-9848
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9848
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Keegan Witt
>            Priority: Major
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)