iOS ● ○ ○ Swift 6

Kodebits Day 39: Struct Value Copy

Jun 12 2026
Practice structs with a short swift challenge.

What does this print?

struct Point {
  var x: Int
  var y: Int
}
var a = Point(x: 3, y: 5)
var b = a
b.x = 9
print(a.x)
print(b.x)


Try it in the online Swift Playground →

[spoiler title="Solution"]

Answer:

3
9

Explanation:

Structs are value types, so b gets an independent copy of a.

[/spoiler]


Further Reading