[prev in list] [next in list] [prev in thread] [next in thread]
List: groovy-user
Subject: Re: [groovy-user] Problems with Maps
From: John Wilson <tug () wilson ! co ! uk>
Date: 2004-08-31 16:24:27
Message-ID: 3AB8AA51-FB6A-11D8-A0BB-000A95B9441C () wilson ! co ! uk
[Download RAW message or body]
On 31 Aug 2004, at 17:03, NetBean wrote:
>
>
> Hi, I have the following a snippet of
> a program I am using to store and then
> postprocess a Map of values... but
> the behaviour is not as expected
> when I am retrieving the values using
> the key.
>
>
> ============= snippet ==============
>
> jlick = [:] # init empty map
> for ( i in 1..5) {
> k = "val is :${i}";
> jlick.put("${i}",k);
> }
> m = 2;
>
> ## I tried to use one of the following
> ## ways to get the value back using
> ## a key.
>
> #num = jlick.get("${m}");
> #num = jlick.get("2");
> #num = jlick.get(2);
> #num = jlick.2;
>
> println("it is >${num}<");
>
> ============= snippet ==============
>
> Here's my results...
>
> # returns correct value
> m = 2;
> num = jlick.get("${m}");
>
> # returns null for num
> #num = jlick.get("2");
>
this is a bug.
println "${2}".hashCode() == "2".hashCode()
prints
false
println "${2}" == "2"
prints true
The hashCodes should be identical.
I'll raise an issue and fix it for you.
John Wilson
The Wilson Partnership
http://www.wilson.co.uk
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic