zlox/samples/ch8_initalizers.lox

18 lines
293 B
Plaintext
Raw Permalink Normal View History

2024-08-31 11:32:05 +02:00
class Brunch {
var food;
var drink;
init(food, drink) {
this.food = food;
this.drink = drink;
}
fun get_recipe() {
return this.food + " " + this.drink;
}
}
var instance = Brunch("eggs", "coffee");
print instance;
print instance.get_recipe();