Created
March 26, 2018 19:39
-
-
Save tuvokki/5a29dd8d690808ce9bfb754fbdf50b83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iex(1)> lala = fn(msg) -> send self(), {:hello, msg} end | |
#Function<6.99386804/1 in :erl_eval.expr/5> | |
iex(2)> lala.("hehe") | |
{:hello, "hehe"} | |
iex(3)> lala.("hoho") | |
{:hello, "hoho"} | |
iex(4)> getst = fn() -> receive do {:hello, msg} -> "Got this #{inspect msg}" after 1_000 -> "Nothing after 1s" end end | |
#Function<20.99386804/0 in :erl_eval.expr/5> | |
iex(5)> getst.() | |
"Got this \"hehe\"" | |
iex(6)> getst.() | |
"Got this \"hoho\"" | |
iex(7)> getst.() | |
"Nothing after 1s" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment