Constructors

This commit is contained in:
2026-04-11 17:05:20 +10:00
parent 2e7b5b7480
commit 1dedb30a87
8 changed files with 248 additions and 21 deletions

View File

@@ -1,18 +1,16 @@
use io
struct Person {
name = ""
age = 0
def greet() string {
return "Hello, " + self.name + "!"
}
struct dingus {
x = 5
y = "dingus"
constructor(string name, int age) {
self.name = name
self.age = age
}
}
e = new dingus
puts e
puts dingus
puts e.x
println(e.y)
e.x = 7
e.y = "heheheha"
puts e.x
println(e.y)
max = Person("Max", 16)
puts max
puts max.greet()