Is this really a class?

Report a typo

We have a game state class:

class GameState(val phase: String, val playerIds: Set[Int])

Change the class without writing new methods so we can copy the state of the game by adding players:

val state = GameState("waiting", Set.empty)

state.copy(playerIds = state.playerIds + 1) // GameState("waiting", Set(1)) 

Sample Input 1:

Sample Output 1:

Write a program in Scala 3
class GameState(val phase: String, val playerIds: Set[Int])
___

Create a free account to access the full topic