Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's difference between array and tuple [duplicate]

I've started to learn what does tuple mean and I faced with the question what's difference between Array and Tuples. So, I'm just schoolboy who want to learn Swift and I still don't know a lot of things

like image 336
Nick Avatar asked Mar 01 '18 10:03

Nick


People also ask

What is the difference between tuple and array?

Tuples have a slight performance improvement to lists and can be used as indices to dictionaries. Arrays only store values of similar data types and are better at processing many values quickly.

Can tuples have duplicates?

Tuples A Tuple represents a collection of objects that are ordered and immutable (cannot be modified). Tuples allow duplicate members and are indexed.

Is a tuple like an array?

The Tuple type represents a JavaScript array where you can define the data type of each element in the array. a tuple is a special type of array that stores multiple fields belonging to the different data types into the same collection. It is similar to the structures in the c programming language.

What is the difference between tuple and array in typescript?

The structure of the tuple needs to stay the same (a string followed by a number), whereas the array can have any combination of the two types specified (this can be extended to as many types as is required).


1 Answers

Tuple A tuple is a grouping of unnamed, ordered values. Each value in a tuple does not need to be the same type.

Array An array is mutable collection. They are very efficient to create, but must always be a single type.

like image 68
Taimoor Suleman Avatar answered Oct 03 '22 17:10

Taimoor Suleman