Swift: A simple struct

This entry is part 31 of 41 in the series Swift

If Inheritance is not needed in a class object, it might be better to use struct instead.

struct Coordinate {
    var x: Int
    var y: Int
    init(x: Int, y: Int) {
        self.x = x
        self.y = y

let center = Coordinate(x: 10, y: 20)




Series Navigation<< Swift: Testing if there are parameters in a function called
Swift: A simple rectangle struct >>

Leave a comment

Leave a Reply