This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
devlogs:8_5_2022 [2022/05/09 23:00] root |
devlogs:8_5_2022 [2023/10/19 15:25] (current) |
||
---|---|---|---|
Line 131: | Line 131: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | == Wow tuples! == | ||
+ | Tuples are kinda like arrays but they can hold different types of data. | ||
+ | |||
+ | <code rust> | ||
+ | let i = (2.0," | ||
+ | </ | ||
+ | |||
+ | but like whadoo?? how do you use it? | ||
+ | |||
+ | <code rust> | ||
+ | fn main() { | ||
+ | let i = (2," | ||
+ | let (num, | ||
+ | let anotherNum = i.0; //Lol yeah you can access it like that too | ||
+ | let anotherString = String:: | ||
+ | match i { | ||
+ | | ||
+ | //IF first is 0 and then Destructure the second and third elements | ||
+ | (0, y, z) => println!(" | ||
+ | (1, ..) => println!(" | ||
+ | // | ||
+ | | ||
+ | // `_` means don't bind the value to a variable | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | that is all. | ||
~~DISCUSSION | Gosy ~~ | ~~DISCUSSION | Gosy ~~ |