Okay so in this video we're going to talk about tuples. So 1
let's say you want to create an array of RGB colors, okay? RGB 2
colors are three colors that takes the form of numbers and 3
that can be between 0 and 255. So I can have something this, this 4
and for example this, okay? So if you want to type this 5
correctly, yes, obviously you're going to make that an 6
array of numbers, okay? But by doing that I can still add 7
other values like this and that's not exactly what I want 8
so you can be more strict and you can basically type every 9
item of your array okay every tuples so you can do something 10
like this number number and number and as you can see now 11
it's not valid anymore as you can see here I have six numbers 12
but this is not assignable to three numbers like this so by 13
the that I'm forcing my array to have only three cells that 14
contains each a number okay and you could for example make that 15
a string if you want or something else and you would 16
have to do something like this if you want it to compile okay 17
and obviously you can send any type okay you can create your 18
own interfaces, your own types so this is cool but be super 19
careful because you still can do something like this you can 20
still do RGB. push and as you can see here the push is 21
offering me to push strings or numbers and I can do for 22
example this if I want okay and then I can console log RGB 23
and as you can see I now have four values so be super careful 24
because type script has no way to know if it's still okay to 25
do that or not okay but it can be very useful if you don't 26
intend to modify the value for example here we are modifying 27
the value but this can be very useful if you for example don't 28
intend to modify the value for example if you make that 29
read only, well you cannot push an more so that's cool and the 30
type will always be good. Okay? Um all right so that's pretty 31
much about tuples. I hope it's clear and see you on the next 32
one.