r/ProgrammerHumor • • Oct 13 '26

Meme howProgrammingHasChanged

Post image
676 Upvotes

108 comments sorted by

View all comments

Show parent comment

9

u/Fadamaka Oct 14 '26

Yes, iirc for all of your questions. You don't need to use the return keyword in rust. Also I vaguely remember that you cannot even use it in a traditional way because the compiler is going to yell at you.

8

u/LuigiWasRight447 Oct 14 '26

Wow. I do not like that lol

3

u/Street-Session9411 Oct 14 '26

Rust is unlike traditional programming languages, expression based. Means you either need to complete your functions with an expression rather than a statement (which `return something;` is) or your whole function needs to be an expression. It’s weird at the beginning but after a time it feels natural. You can basically copy the code of a function 1:1 and replace a function call with it and it will compile, which is something that would not work in a traditional language that is solely statement based. You could basically replace the condition of an if-statement with 100 lines of code that evaluates to a boolean value and it would work. Obviously you don’t gain anything from that but imo it’s how things are supposed to be.

2

u/blaqwerty123 Oct 14 '26

You get used to it, i did not like it at first either