hardStudy question · answer published in Swift interview questions, so no pointsswiftvalue-typesperformance
When a Swift array is copied
When is the array storage actually copied, and what does this code print?
var a = [1, 2, 3] var b = a // (1) b.append(4) // (2) print(a.count, b.count)
Discussion 0
Join free to post in the discussion.
Related questions
- Network calls on the main threadMobile App Developer
- Safely unwrapping a Swift optionalMobile App Developer
- Swift struct assignment copiesMobile App Developer
- Swift class shared referenceMobile App Developer
- Decoding JSON with extra keysMobile App Developer
- Testing speed on a debug buildMobile App Developer
- App Not Responding dialogMobile App Developer
- NetworkOnMainThreadExceptionMobile App Developer