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