Is Swift Pass By Value or Pass By Reference

后端 未结 9 742
[愿得一人]
[愿得一人] 2020-11-22 10:04

I\'m really new to Swift and I just read that classes are passed by reference and arrays/strings etc. are copied.

Is the pass by reference the same way as in Objecti

9条回答
  •  借酒劲吻你
    2020-11-22 10:40

    Swift assign, pass and return a value by reference for reference type and by copy for Value Type

    [Value vs Reference type]

    If compare with Java you can find matches:

    • Java Reference type(all objects)
    • Java primitive type(int, bool...) - Swift extends it using struct

提交回复
热议问题