Conflicting definition of Swift struct and array

后端 未结 6 1019
孤街浪徒
孤街浪徒 2021-02-01 09:56

In Swift Programming Language, it says:

  1. “all of the basic types in Swift—integers, floating-point numbers, Booleans, strings, arrays and dictio

6条回答
  •  离开以前
    2021-02-01 10:43

    The Array is struct:

    struct Array : MutableCollection, Sliceable {...}
    

    And all struct are always copied when they are passed around in the code. Classes are passed by reference.

    So the Array are value types.

提交回复
热议问题