You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "John Wagenleitner (JIRA)" <ji...@apache.org> on 2016/04/02 00:20:25 UTC
[jira] [Closed] (GROOVY-7790) Put the value in get method with
default value
[ https://issues.apache.org/jira/browse/GROOVY-7790?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Wagenleitner closed GROOVY-7790.
-------------------------------------
Resolution: Not A Problem
Since the [GDK docs|http://docs.groovy-lang.org/latest/html/groovy-jdk/java/util/Map.html#get(java.lang.Object,%20java.lang.Object)] specify {{defaultValue}} as
{quote}
the value to return and add to the map for this key if there is no entry for the given key
{quote}
It looks like your results match what is specified. If we are missing something, please reopen and let us know. Thanks.
> Put the value in get method with default value
> -----------------------------------------------
>
> Key: GROOVY-7790
> URL: https://issues.apache.org/jira/browse/GROOVY-7790
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Reporter: Maoxiang Qian
>
> I'm not sure whether it was designed, but it seems to be weird.
> {code:Java}
> groovy> imap=['a':1, 'b':2]
> groovy> if(imap.get('c',null)==null){ }
> groovy> imap.each{k, v -> println "${k}:${v}" }
> a:1
> b:2
> c:null
> Result: [a:1, b:2, c:null]{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)