1.

Predict the output of the following ios Swift program:

Answer»

var item = "apples"let CLOSURE = { [item] in print("He wanted to eat \(item)")}item = "oranges"closure()

The output of the given code snippet will be "He wanted to eat apples". When we define the closure, the capture list generates a duplicate of the item. This MEANS that EVEN if you MODIFY the value of an OBJECT, the captured value remains the same.



Discussion

No Comment Found