Write Antril, run it in your browser and share it with a link. Programs are compiled to WebAssembly and run on your machine, not on the server.
Running programs is unavailable right now: the WebAssembly linker (wasm-ld, part of LLVM) is not installed on this server. You can still write, share and download code.
importSystem;
intonamespaceGen
{
publicclassBox<T>
{
T item;
public:
new(T item) { this.item = item; }
Get() : T => item;
}
publicstaticclassCounter
{
public:
statici32Start;
staticnew() { Start = 40; }
}
First<T>(T[] items) : T => items[0];
Twice<T : INumber<T>>(T x) : T => x + x;
AddChecked(i32 a, i32 b) : i32 => checked(a + b);
Main()
{
Box<str> b = newBox<str>("hi");
Console.WriteLine(b.Get());
Console.WriteLine(First<i32>([1, 2, 3]));
Console.WriteLine(Twice<i32>(21));
Console.WriteLine(AddChecked(Counter.Start, 2));
any boxed = 42;
Console.WriteLine(boxed);
}
}
Output
Press Run (or Ctrl+Enter) to compile and run the program.
Input
What Console.ReadLine() reads, one line at a time.
Ctrl+Enter runs. Tab indents (Shift+Tab outdents); press Esc, then Tab, to leave the editor. A program may run for 10 seconds.