return
is for early results in Motoko (tweet)
#4831
ggreif
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
You can prematurely leave a Motoko function (or
async
expression) with thereturn ⟨res⟩
expressions, should the circumstances allow it. (Here⟨res⟩
is optional and defaults to unit:()
). Notably though, you don't need areturn
when falling off the end of the function with a result (as most modern languages, like Rust and Wasm). We suggest that you only early-return
.Beta Was this translation helpful? Give feedback.
All reactions