Question about chapter 18 first ios and swiftUI app

@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.

This topic was automatically closed after 166 days. New replies are no longer allowed.