Skip to content

Instantly share code, notes, and snippets.

@kevsmith
Created August 25, 2011 02:23
Show Gist options
  • Select an option

  • Save kevsmith/1169817 to your computer and use it in GitHub Desktop.

Select an option

Save kevsmith/1169817 to your computer and use it in GitHub Desktop.
Multi-headed anon function example
2> F = multi_head:make_fun().
#Fun<multi_head.0.128697214>
3> F(foo).
ok
4> F(bar).
less_ok
5> F(baz).
really_bad
6> F(quux).
** exception error: no function clause matching
multi_head:'-make_fun/0-fun-0-'(quux)
7>
-module(multi_head).
-compile([export_all]).
make_fun() ->
fun(foo) ->
ok;
(bar) ->
less_ok;
(baz) ->
really_bad
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment