Why to use tuples when we can use array to return multiple values in swift

前端 未结 4 1855
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 13:51

Today I was just going through some basic swift concepts and was working with some examples to understand those concepts. Right now I have completed studying tuples.

4条回答
  •  执念已碎
    2020-12-02 14:13

    Tuple is a datastructure which is lighter weight than heterogeneous Array. Though they're very similar, in accessing the elements by index, the advantage is tuples can be constructed very easily in Swift. And the intention to introduce/interpolate this(Tuple) data structure is Multiple return types. Returning multiple data from the 'callee' with minimal effort, that's the advantage of having Tuples. Hope this helps!

提交回复
热议问题