summaryrefslogtreecommitdiff
path: root/examples/functions.fy
blob: 15856a05faefda0e91c3dfe1fda7c879243ed369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#*
 * Examples of how to use functions
 *#

func foo {
	say 1 + a * 3 + b;

	func bar {
		say "Hello i am nested";
	}

	bar; # Calling nested
}

my a = 2, b = 4; # Create global variables
foo;
assert 0 == (defined bar); # bar is not available anymore

func baz {
	say "I am baz";
	undef baz; 
}

baz; # Baz deletes itself
assert 0 == (defined baz); # baz is not available anymore