I am writing a small game, and part of this is to track player ratings. For this, I have a card initialized as follows:
// given: players: List<Player> var scores: MutableMap<Player, Int> = mutableMapOf(*players.map { it to 0 }.toTypedArray())
My concern is that I need to use .toTypedArray() for the result of map { it to 0 } before I can apply the spread operator * . Is there any way to avoid this? The same problem occurs when creating a map by fastening two arrays:
blubb source share