From 1d3046892f24eb14342b331508e324b049d683a2 Mon Sep 17 00:00:00 2001 From: Username404 Date: Fri, 8 Apr 2022 10:53:19 +0200 Subject: [PATCH] Change the syntax for anonymous functions in docs/gettingstarted.md Signed-off-by: Username404 --- docs/gettingstarted.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/gettingstarted.md b/docs/gettingstarted.md index 0f6611b..1a3a146 100644 --- a/docs/gettingstarted.md +++ b/docs/gettingstarted.md @@ -7,15 +7,13 @@ helloworld #= "Hello, World!" ## 2 - (Anonymous) Functions You can make an anonymous functions using the following syntax: ``` -getHelloWorld: ~String => { +getHelloWorld: ~String #= { return "Hello, World!" } ``` The type (`~String` here, which basically means "an anonymous function that returns a String") can be omitted, see [#3](#3---types). -Note that you can make `getHelloWorld` final by replacing `=>` with `#=>`. - -To define a **named** (and mandatorily final) function, replace `=>` with `>>`: +To define a **named** (and mandatorily final) function, replace `#=` with `>>`: ``` getHelloWorld: String >> { return "Hello, World!" @@ -25,7 +23,7 @@ getHelloWorld: String >> { ### 2.1 - Main Main can be a variable named `main` that contains an anonymous function, a function named `main` or a function that has the `as_main` attribute: ``` -main #=> {} +main #= {} main >> {} as_main helloWorld >> {} ``` @@ -33,7 +31,7 @@ as_main helloWorld >> {} ### 2.2 - Function parameters Parameters can be added to an anonymous function by specifying the types as follows: ``` -addIntToString (int, String) => { a, b; +addIntToString: (int, String)~ #= { a, b; print_line(b + a) } ```