Skip to content

mutable.Map.getOrElseUpdate issue #10703

Closed
@igreenfield

Description

@igreenfield

If you use recursive getOrElseUpdate you can easily end up with a map that contains the same key twice with different values:

val map = mutable.Map[String, String]()

map.getOrElseUpdate("key", {
  map.getOrElseUpdate("key", "value1")
  "value2"
})

map

The second call could come from another place in the application this is just a sample.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions