plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
41e0859
— Peter John
2026-08-09T21:12:47+05:30
docs: update methods section for nested-only method declaration syntax
README.md
CHANGED
|
@@ -272,18 +272,18 @@ Full example: [`examples/closures.plum`](examples/closures.plum).
|
|
|
272
272
|
|
|
273
273
|
### `self`, field access, and methods
|
|
274
274
|
|
|
275
|
-
A
|
|
275
|
+
A `fun` declared indented directly inside a `type`/`enum` body is a method on that type, with an implicit `self`:
|
|
276
276
|
|
|
277
277
|
```plum
|
|
278
278
|
type Cat =
|
|
279
279
|
name: Str
|
|
280
280
|
age: Int
|
|
281
281
|
|
|
282
|
-
fun getAge
|
|
282
|
+
fun getAge(self) -> Int =
|
|
283
|
-
|
|
283
|
+
self.age
|
|
284
284
|
|
|
285
|
-
fun birthday
|
|
285
|
+
fun birthday(self) -> Int =
|
|
286
|
-
|
|
286
|
+
self.age + 1
|
|
287
287
|
|
|
288
288
|
fun main() -> Int =
|
|
289
289
|
c = Cat(name: "Whiskers", age: 3)
|