Add class support with constructors, fields, and methods

This commit is contained in:
Jose Luis Montañes Ojados
2026-02-19 04:24:44 +01:00
parent f2e90efc16
commit d8b4f9b2ea
9 changed files with 660 additions and 117 deletions

11
projects/classes.j Normal file
View File

@@ -0,0 +1,11 @@
class Dog:
fn init(self, name):
self.name = name
fn bark(self):
println("guau!")
d = Dog("ahi te va")
x = d.bark()
println("Hola ", d.name)
debugHeap()

View File

@@ -1,4 +1,8 @@
fn greet(name):
println("Hola, " + name)
x = "Hello world!"
greet("mundo!")
fn suma(x, y):
fn pow(z):
return z * z
return x + pow(y)
println(suma(2, 2))