[Example]添加函数示例
This commit is contained in:
15
ExampleCodes/2-Function.fig
Normal file
15
ExampleCodes/2-Function.fig
Normal file
@@ -0,0 +1,15 @@
|
||||
func greeting(name:String) -> String
|
||||
{
|
||||
return "Hello " + name + "!";
|
||||
}
|
||||
|
||||
const print := __fstdout_println; // link to std out
|
||||
print(greeting("Fig"));
|
||||
|
||||
func adder(x)
|
||||
{
|
||||
return func (n) => x + n; // closure
|
||||
}
|
||||
|
||||
const add2 = adder(2);
|
||||
print(add2(3));
|
||||
Reference in New Issue
Block a user