Escribe Antril, ejecútalo en tu navegador y compártelo con un enlace. Los programas se compilan a WebAssembly y se ejecutan en tu equipo, no en el servidor.
Ejecutar programas no está disponible en este momento: the WebAssembly linker (wasm-ld, part of LLVM) is not installed on this server. Aún puedes escribir, compartir y descargar código.
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);
}
}
Salida
Pulsa Ejecutar (o Ctrl+Enter) para compilar y ejecutar el programa.
Entrada
Lo que lee Console.ReadLine(), una línea a la vez.
Ctrl+Enter ejecuta. Tab agrega sangría (Shift+Tab la quita); pulsa Esc y luego Tab para salir del editor. Un programa puede ejecutarse durante 10 segundos.