Conflicting definition of Swift struct and array

后端 未结 6 1017
孤街浪徒
孤街浪徒 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:50

    Array in swift are value type when i try the following code:

    var myArray1 = [1, 2, 3]
    var myArray2 = myArray1
    myArray2 += 4;
    println(myArray1);
    println(myArray2);
    

    It print different value for myArray1 and my Array2. If they share same reference the value must be same.

提交回复
热议问题