annotate 5-Erlang/matching_function.erl @ 74:41c7cd909218
Write up exercises for Erlang day 2 (including bonus Tic Tac Toe)
author |
IBBoard <dev@ibboard.co.uk> |
date |
Sat, 03 Feb 2018 19:53:28 +0000 |
parents |
32f018861e36 |
children |
|
rev |
line source |
71
|
1 -module(matching_function).
|
|
2 -export([number/1]).
|
|
3
|
|
4 % Like Prolog, we can define different function matches as "overrides" of the function
|
|
5 % with the same name/parameter count but different "fixed" values
|
|
6 % For some reason these are separated by semi-colons here
|
|
7 number(one) -> 1;
|
|
8 number(two) -> 2;
|
|
9 number(three) -> 3.
|
|
10
|
|
11 % Calling this with any value or atom other than one, two or three will fail. |