Rust Tutorial #8 - Functions, Expressions & Statements

preview_player
Показать описание
Hello everyone, and welcome to video number eight in this Rust Programming tutorial series. In this video I will be presenting Rust functions, expressions and statements. I will show you how to create, call and use basic functions, along with the difference between statements and expressions in Rust. Finally, I'll wrap up with the process of returning values from functions. Enjoy the video!

⭐️ Timestamps ⭐️
00:00 | Introduction
00:48 | Creating Functions
03:39 | Function Parameters
05:08 | Statements vs Expressions
10:32 | Returning From Functions

◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️

◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️

⭐️ Tags ⭐️
-Tech With Tim
-Rust
-Rust Programming Language
-Rust Not The Game
-Learn Rust Programming
-Rust Arithmetic

⭐️ Hashtags ⭐️
#TechWithTim #RustProgramming
Рекомендации по теме
Комментарии
Автор

5:58 in Python "x = 20" is also not an expression, you can do "y = x = 20" because the syntax of an assignment statement allows assigning to multiple variables.
You can't use it as an expression, for example `y = 2 * (x = 20)` is invalid.
Although, Python 3.8 added the walrus operator (which you did a video on) which is exactly what you meant: `y = 2 * (x := 20)`

AssemblyWizard
Автор

Thanks for this tutorial. Coming from javascript i was really happy at 12:51

jippi
Автор

Hey Tim... Semicolon, semicolon, semicolon... This rust series is great, thanks!

michaelguerrero
Автор

Just adding a bit, a lot of things in rust are expressions, "if {} else if {} else {}" is an expression, "for", "loop", "while" loops are expressions, "match" blocks are also expressions.

You can write some really neat code and avoid mutability in you code if you use these expressions well.

ythanzhang
Автор

Interesting series so far! In Ruby, there's a similar behavior where if you end a function on an expression, that becomes the return value. You can also be explicit and say "return x".

johnpricejoseca
Автор

9:20 Scala supports block expressions, and Kotlin supports `if-else` expressions

AssemblyWizard
Автор

Nice! I just want to say 'thank you' for motivating me to start a Tech Youtube channel myself. Thanks for the content!

felixc.programs
Автор

interesting the syntax reminds me a lot of C++.

yunfeichen
Автор

Yoo whats up. Really appreciate the fact that you take the time to teach a language that other people may want to learn . Your code is really *rusty* good programming! Get it? Rust!
One request - could you make a video on the python ursina module? Like and fps game with it.? Thanks for the time

ChessQuickies
Автор

Block Expressions do exist in a few other languages, e.g. they are supported in C/C++ as a GCC extension called Statement Expressions. Though I generally dislike the very implicit weird syntax for this.

lal
Автор

Tim can you make a algorithms and DataStructures series?

pravachanpatra
Автор

At 12:06, "I always forget the damn semicolon;" XD

farhanferoz
Автор

I forgot i was watching this video for a moment and just ended up making a calculator haha💪

bossrazorback
Автор

Can't wait for this awesome language to take over C and C++.

dyspatch
Автор

Does Rust allow nested functions, where the scope of the nested function is purely restricted to be within the host?

lsatenstein
Автор

I swear every frickin video he forgets the semicolon!

TizzyT
Автор

regarding return, why wouldn't you just write fn add_numbers(x: i32, y: i32) -> i32{ return x + y;} ?

jlchavis
Автор

When are semicolons at end of statements not required? Checkout the video at around 5.10-5.20 println!( "The sum is {}", x + y )
What are the rules about end-of-line entries.

lsatenstein
Автор

Hey Tim, now that you're are making this rust series how about making a Chip-8? It's a pretty basic emulation project and will give an introduction to bitwise operations and low level programming

maypher
Автор

could you pls explain should we learn cpp or rust? cons and pros? job market and future of them? I already know python, thank you!

jimjimjim