Is there a more concise way in swift to display the graph view for an Array
's (or other collection's) values in the playground side-bar, other than manually iterating the values?
Other than:
for x in array { x }
Is there a more concise way in swift to display the graph view for an Array
's (or other collection's) values in the playground side-bar, other than manually iterating the values?
Other than:
for x in array { x }
Only so slightly conciser, but you see the same graph view using .map
:
array.map{ $0 }
As described in the follinwg Q&A:
The explicit captureValue(_:withIdentifier)
approach—as previously covered in this answer as an alternative approach to the Playground-automatically displayed graphs—has been deprecated in Xcode 7.3.
We could previously explicitly display the same graph view in the playground:s timeline (as opposed to the playground:s sidebar) by using XCPlaygroundPage
method .captureValue(_:withIdentifier)
import XCPlayground
let array = Array(1...10)
array.map{XCPlaygroundPage.currentPage.captureValue($0, withIdentifier: "My numbers")}
The identifier "My numbers"
would serve as a title for the displayed graph in the timeline.
To show the timeline: show the assistant editor (View -> Assistant Editor -> Show Assistant Editor
).
See also the following thread regarding the (now deprecated) captureValue(...)
method: