To start with, semicolons act differently when you’re in the REPL or IJulia
compared to in a script. In the REPL/IJulia, the semicolon suppresses
output, so that there’s a difference between
julia> 3;
and
julia> 3
3
but in a script no output is produced without explicit print statement
irregardless of semicolons.
I think your confusion might stem from thinking that 2; would actually
parse as begin 2; nothing end, but that is - as you noticed - not the case.
To suppress the return value in your code, you probably want this:
function whatev(fun)
fun()
end
u = whatev() do
2
nothing
end
@show u
// T
On Wednesday, October 14, 2015 at 3:05:30 PM UTC+2, Cedric St-Jean wrote:
I keep running into cases where I expect the semi-colon to remove the
> output (return nothing), but something is returned. Am I misunderstanding
> the semi-colon's role as a separator, or is that a parser bug?
>
> function whatev(fun)
> fun()
> end
> u = whatev() do
> 2;
> end
> @show u
> > u = 2
>
>
>