- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
withDefault and withDefaultValue for mutable maps
Mon, 2010-09-06, 23:31
This is a follow up to this stackoverflow question
http://stackoverflow.com/questions/3648870/scala-using-hashmap-with-a-de....
This works with immutable maps: Map(1 -> "b", 2 ->
"a").withDefaultValue("-").
It seems this would be practical with mutable maps as well. There is also a
comment in
http://www.scala-lang.org/api/current/scala/collection/immutable/Map.html
that suggests that withDefault could move to general map.
Should I submit a enhancement request ticket? I was not able to find
anything with Map and withDefault keywords.
--huynhjl
Tue, 2010-09-07, 15:17
#2
Re: withDefault and withDefaultValue for mutable maps
Martin Odersky wrote:
>
> On Tue, Sep 7, 2010 at 12:31 AM, huynhjl wrote:
>>
>> This is a follow up to this stackoverflow question
>> http://stackoverflow.com/questions/3648870/scala-using-hashmap-with-a-de....
>>
>> This works with immutable maps: Map(1 -> "b", 2 ->
>> "a").withDefaultValue("-").
>>
>> It seems this would be practical with mutable maps as well. There is also
>> a
>> comment in
>> http://www.scala-lang.org/api/current/scala/collection/immutable/Map.html
>> that suggests that withDefault could move to general map.
>>
> Yes, please do!
>
On Tue, Sep 7, 2010 at 12:31 AM, huynhjl wrote:
>
> This is a follow up to this stackoverflow question
> http://stackoverflow.com/questions/3648870/scala-using-hashmap-with-a-de....
>
> This works with immutable maps: Map(1 -> "b", 2 ->
> "a").withDefaultValue("-").
>
> It seems this would be practical with mutable maps as well. There is also a
> comment in
> http://www.scala-lang.org/api/current/scala/collection/immutable/Map.html
> that suggests that withDefault could move to general map.
>
Yes, please do!