This is due to how pipes work: they call the function on the right with the value on the left, which is not what you want here: doing
signal_connect(b, "clicked") do w
println(w, " was clicked")
end
is an alternative syntax for
signal_connect(w->println(w, " was clicked"), b, "clicked")
In both cases the callback is passed as first argument, as required by signal_connect.
On the other hand, the following
signal_connect(b, "clicked") |> w->println(w, " was clicked!")
tries to execute signal_connect(b, "clicked") and pass the result to the function w->println(w, " was clicked!"). Another way to look at it: the following uses the pipe syntax correctly:
"hello" |> w->println(w, " was clicked!")
Obviously you cannot replace “hello” with the signal_connect call…