Created
August 25, 2011 02:23
-
-
Save kevsmith/1169817 to your computer and use it in GitHub Desktop.
Multi-headed anon function example
This file contains hidden or 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
| 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> |
This file contains hidden or 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
| -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