Thuta Learning
ရှာဖွေရန်
IntermediateProgrammingintermediate

Tuples

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

Tuple သည် fixed number of elements များပါဝင်ပြီး element တစ်ခုချင်းစီ၏ type ကို သိရှိသော array အမျိုးအစားတစ်ခုဖြစ်သည်။

typescript
// Declare a tuple type
let user: [number, string];

// Initialize it
user = [1, "Steve"];

// user = ["Steve", 1]; // Error: Type 'string' is not assignable to type 'number'.

console.log(user[1]);
You should see
Steve
Tuples | Thuta Learning