All examples
Language

Concise generic classes

Use private fields, implicit receivers, and inferred result types without repetitive method syntax.

Download .aner source
oop_concise.aner
// Input types are explicit; receiver and result types can be inferred.
class Cell<T> {
    let initial: T
    var value: T

    fn get() { return value }
    fn set(value: T) { self.value = value }
    fn reset() { set(initial) }
    fn preview() {
        let value = initial
        return value
    }
}

let counter = Cell<Int64>(initial: 0, value: 10)
print(counter.get())
counter.set(25)
print(counter.get())
print(counter.preview())
print(counter.get())
counter.reset()
print(counter.get())

Make it your experiment.

With Aner installed, save this program as examples/oop_concise.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/oop_concise.aner
aner run examples/oop_concise.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Iris and Wine are teaching datasets with their own attribution. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner