Swift: How to assign a variable by reference, not by value?

前端 未结 4 1749
青春惊慌失措
青春惊慌失措 2020-12-19 02:08

I\'m trying to get a reference to an Array and make modifications to it. Because Arrays in Swift are value types, instead of reference types, if I

4条回答
  •  春和景丽
    2020-12-19 02:42

    You cannot assign an array to a variable by reference in Swift.

    "In Swift, Array, String, and Dictionary are all value types..."

    Source: https://developer.apple.com/swift/blog/?id=10

提交回复
热议问题