Bonjour!!!
I am back... it's been a while, but lets continue!!!
Next thing in rustlings is control flow which is very easy but if u come from C maybe a bit tricky. But nothing difficult!!!
The keywords are:
if <condition> {} // first condition
else if <condition> {} // other condition
else {} // none condition is true
nothing from another world. But you need to know that, <condition>
has to be a bool, otherwise you will get an error.
Ternary conditions are weird... I like more C.
if <condition> { } else { }
You need those {}
otherwise the compiler will say something like
The next thing I had to do was a quiz, very easy you don't miss nothing, except for one thing I have discovered!!
When u are using, say i8 and u want to return or you need it to be i32. There are two ways:
-
into
let i: i8 = 0;
let x: i32 = i.into();
-
from
let i: i8 = 0;
// u don't even need to specify here xd
let x: i32 = i32::from(i);
from is recommended by the docs
Follow me!
(I liked more the red bird :_()
π¦ Twitter
π GitHub
π₯ LinkdIn
Top comments (0)