Playground
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.
Run
Stop
Examples
Examples…
What is in the project
Change the program
Basics
Files and namespaces
Variables and constants
Literals
loop
switch
Strings
Classes
Fields and constructors
Values
Inheritance and interfaces
Enums
Records
Tuples
Nullable types
Functions and methods
Lambdas and function types
Iterators
Generics
Constraints
Variadic generics
Operators
Extension blocks
Errors and exceptions
Catching
Destructors
Manual memory
Regions
Unsafe code and pointers
Fixed buffers
async and await
Exceptions
Reactive code
Share
Download .ant
Link to this program
Copy link
import System ;
into namespace Bank
{
public class Account
{
public :
new (str owner, i32 start)
{
this.owner = owner;
balance = start;
Opened += 1 ;
}
str Owner { get => owner; }
i32 Balance { get { return balance; } private set { balance = value; } }
static i32 Opened { get ; set ; }
Deposit (i32 amount)
{
Balance = balance + amount;
}
private :
str owner;
i32 balance;
}
Main ()
{
Account a = new Account ("Ana" , 10 );
a.Deposit (5 );
Account b = a;
b.Deposit (1 );
Console .WriteLine (a.Owner + " has " + a.Balance );
Console .WriteLine (Account .Opened + " account opened" );
}
}
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.