Could someone explain why these two lines act differently? activeGames is a MutableMap<String, Game>.
val game = activeGames.getOrDefault(id, Game(id))
val game = activeGames[id]?:Game(id)
For whatever reason, whenever I pass in the id key for a game that I know exists, calling getOrDefault always does the default behavior of creating a new game instead of grabbing the game from the map. But the line with the elvis operator works like I expect, and gets the existing game from the map.
I am instantiating activeGames with:
val activeGames = mutableMapOf<String, Game>()