plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
plum-examples/methods.plum
import std/Str
import std/Bool
import std/Number
enum Cat =
| Cat(name: Str, age: Int)
fun getAge(self) -> Int =
self.age
fun birthday(self) -> Int =
self.age + 1
enum Wrapper =
| Wrapper(inner: Cat, tag: Int)
fun innerAge(self) -> Int =
self.inner.age
fun makeCat() -> Cat =
Cat(name: "Whiskers", age: 3)
fun main() -> Int =
c := makeCat()
a := c.getAge()
b := c.birthday()
w := Wrapper(inner: c, tag: 1)
a + b + w.innerAge()
test "methods example computes correctly"
assert main() == 10