-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
The
return
keyword should always be omitted from return statements within short-form method definitions (f(...) = ...
). Thereturn
keyword should never be omitted from return statements within any other context (function ... end
,macro ... end
, etc.).
I think it would be good to clarify/revisit the use of return
statements in do-blocks. Although do-blocks are just functions there are used commonly like if if
/let
/begin
blocks where the last sub-expression returned.
A particularly annoying example of requiring return
statements in do-blocks can be found when working with sprint
:
msg = sprint() do io
Base.showerror(io, e)
Base.show_backtrace(io, catch_backtrace())
println(io)
return nothing
end
Excluding the return
statement reduces confusion where someone might think that msg
would be assigned to nothing
.
Metadata
Metadata
Assignees
Labels
No labels