Files
pebble/examples/basic/20_init.peb

20 lines
379 B
Plaintext

class Person {
init(firstname, lastname) {
this.firstname = firstname
this.lastname = lastname
}
get_fullname() {
return this.firstname + " " + this.lastname
}
greet(person) {
print("Hello " + person.get_fullname())
}
}
let alice = Person("Alice", "Foo")
let bob = Person("Bob", "Bar")
alice.greet(bob)
bob.greet(alice)