Continuing our journey lets try more on functions, until now they were plain simple, we just had the main sample.
Now what about those nice arguments? Here they are.
Can I omit parameters types? Nope, they are mandatory.
A little bit contraditory since we have type inference for other parts of the code, still it’s a good practice decision from Rust’s team to keep things this way.
What if I want to return some value? Well that is not so hard either, we use -> type after parameters declaration.
DO NOT ADD ; when returning expression values.
Remember day 3 post where we talked about statements and expressions? The thing is we should return the expression value and ; transform the line in a statement, statements don’t return values
There is one exception, when using return keyword, which tells Rust to use expression value as the return value, so the following code would be the same as the previous.
We almost got through the basics to grasp the tip of the iceberg, next dungeons we will conquer are: types and loops.
Oh and before you go, remember