xxxxxxxxxx
A struct is a simple way of grouping values together
struct Song {
let title: String
let artist: String
let duration: Int
}
//declare the value here
let song = Song(title: "jffj", artist: "dhdhdhh", duration: 8)
//call the declared value using dot notation.
song.title
song.artist
song.duration
xxxxxxxxxx
struct Player {
var name: String
var highScore: Int = 0
var history: [Int] = []
init(_ name: String) {
self.name = name
}
}
var player = Player("Tomas")
xxxxxxxxxx
basic struct holds properties
struct Song {
let title: String
let artist: String
let duration: Int
}