My code:
import UIKit
let arr: [Int] = [1, 2, 3]
let result = arr.map { x in x + 2 }
result
Here is what an Xcode 16.2 Playground shows for the results:
Where does the extra 5 come from on line 4?
adsfhasdkfkahjsdflasdhhf asdfasdklfhkasdjhfksadhf asdfkhasdfkhjasdflkasdfhksd
You can click on the rectangle beside that result to expand it. It is actually two results squished into one line.
By hovering over each of those squares, parts of your code get highlighted to indicate what the result is referring to. "[3, 4, 5]" highlights the word "result" in let result = ...
and "5" highlights x + 2
.
This is the value of x + 2
the last time it has been evaluated. To see the other values of x + 2
, click on the square next to "5", and it will display a graph showing the value of x + 2
over time. By clicking on a point in the graph, you can read its value.