r/ProgrammerHumor • • 2d ago

Meme howProgrammingHasChanged

Post image
601 Upvotes

103 comments sorted by

View all comments

9

u/Depnids 2d ago

I don't know much about rust, but I am just curious why the last line doesn't have a "return" keyword? Does it just assume the last line is the value to return? Could you include the "return" keyword if you wanted?

3

u/No-Consequence-1863 2d ago

If there is no `;` then the last statement is considered the return value. You can include the return if you want but then you also need the `;` at the end.

2

u/Stunning_Ride_220 1d ago

Darnnnn....'intuitive'

1

u/-Ambriae- 1d ago

It is intuitive, once you realise all statements you can write in functions are expressions, even if they evaluate to the unit type

2

u/Stunning_Ride_220 22h ago

"It is intuitive, once you realise"

That made my day, thank you

1

u/-Ambriae- 21h ago

I don't get your comment

that's how intuition works?

1

u/luziferius1337 19h ago

"intuitive" is often meant to be "you know how it works just by looking at it briefly"