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

Paul King edited comment on GROOVY-9848 at 6/19/23 2:21 AM:
------------------------------------------------------------

[~blackdrag] If we make the change, we can get back the old behavior as follows:
{code:groovy}
assert 'e' == switch('foo') {
  case { [bar: true][it] } -> 'a'
  case { [foo: false][it] } -> 'b'
  case { [foo: null][it] } -> 'c'
  case { [foo: ''][it] } -> 'd'
  case { [bar: false, foo: 42][it] } -> 'e'
  default -> 'f'
}
{code}
Perhaps we can even find a shorthand for that case.


was (Author: paulk):
[~blackdrag] If we make the change, we can get back the old behavior as follows:
{code:groovy}
assert 'e' == switch('foo') {
  case { [bar: true][it] } -> 'a'
  case { [foo: false][it] } -> 'b'
  case { [foo: null][it] } -> 'c'
  case { [foo: ''][it] } -> 'd'
  case { [bar: false, foo: 42][it] } -> 'e'
  default -> 'f'
}
 {code}
Perhaps we can even find a shorthand for that case.

> 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.20.10#820010)

Reply via email to