@State private var game: Game = Game()
what is the Game before the = sign needed?
@State private var game: Game = Game()
what is the Game before the = sign needed?
In your example you don’t need to specify the type for game
because you call Game()
to assign its value. You could declare game
as the following:
@State private var game = Game()
While you don’t have to specify the data type for game
, specifying the type for variables makes it very clear what the data type is for each variable.