Sobes.tech
Junior — Senior

What will be the output result (option 2)

livecode

Task condition

Consider the declaration of a structure encapsulating an integer value, and a sequence of operations in which a closure is created that modifies this value. After calling the closure, output the current property value.

struct IntegerBox {
    var value: Int

    init(_ value: Int) {
        self.value = value
    }
}

var numberBox = IntegerBox(10)

let modify = {
    numberBox.value = 77
}

modify()

print(numberBox.value)