Created
October 14, 2022 18:25
-
-
Save SlimerDude/b76b1ace8ed05e8740043ce490761adf to your computer and use it in GitHub Desktop.
Example Fantom Syntax
This file contains 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
/* Example Fantom Syntax | |
* ===================== | |
* by Steve Eynon 2022 | |
* | |
* Useful for checking syntax highlighter libraries. | |
*/ | |
using util // using pod | |
using util::JsonInStream // using type | |
using util::JsonOutStream as Jos // using type as | |
using [java] java.util::Map$Entry as Entry // using java type as | |
** Fandoc class comment | |
@Serializable { simple=false } | |
internal const class Class01 { | |
const Str hello | |
new make(|This| fn) { | |
fn(this) | |
} | |
Void funcArgs0(|Int, Str| fn1) { | |
fn1(6, "9") | |
fn1.call(6, "9") | |
} | |
Void funcArgs1(|Int a0, Str a1->Buf|? fn2) { | |
// call statically | |
fn2(6, "9") | |
fn2.call(6, "9") | |
fn2.callList([6, "9"]) | |
// call dynamically | |
fn2->call(6, "9") | |
fn2?->call(6, "9") // null safe | |
funcArgs0(|Int a0, Str a1| { | |
echo(a0) | |
}) | |
funcArgs0 |Int a0, Str a1| { | |
echo(a0) | |
} | |
funcArgs0 |Int a0| { | |
echo(a0) | |
} | |
funcArgs0 { | |
echo(it) | |
} | |
this->funcArgs0 { | |
echo(it) | |
} | |
var := Class01 { | |
it.hello = "Pips" | |
} | |
// introspection | |
fn0 := Class01#funcArgs0.func | |
fn1 := #funcArgs0.func | |
var.funcArgs0(fn1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment