r/ProgrammerHumor • • 2d ago

Meme howProgrammingHasChanged

Post image
562 Upvotes

99 comments sorted by

View all comments

8

u/Depnids 1d 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 1d 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 23h ago

Darnnnn....'intuitive'

1

u/-Ambriae- 8h 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 7h ago

"It is intuitive, once you realise"

That made my day, thank you

1

u/-Ambriae- 5h ago

I don't get your comment

that's how intuition works?

1

u/luziferius1337 4h ago

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