Login
You're viewing the discuss.systems public feed.
  • Oct 12, 2026, 11:47 PM

    Here's a couple of Swift constructs I'm pondering.

    Taking the scenario of having (x, y, z) co-ordinates that need to be passed into a function (in a different struct declaration), does it make a difference to put the co-ordinates in a struct versus a tuple?

    struct Coords {
    let x: Int; let y: Int; let z: Int
    }

    func doSomething(coords: Coords) {
    print("\(coords)")
    }

    let point = Coords(x: 1, y: 2, z: 0)
    doSomething(coords: point)

    versus:

    func doSomething(coords: (x: Int, y: Int, z: Int)) {
    print("\(coords)")
    }

    let point = (x: 1, y: 2, z: 0)
    doSomething(coords: point)

    #SwiftLang

    💬 0🔄 0⭐ 0