Object Oriented
01
Basic Class
Classes are defined using the 'class' keyword with an 'init' method as the constructor for property initialization.
spec_manifest.jk
class Jack {
init(name) {
this.name = name
}
func greet() {
println("Hello", this.name)
}
}
let jack = Jack("Jack")
jack.greet()
02
Inheritance
Jackal supports class inheritance using the colon (:) syntax, allowing subclasses to access properties and methods from a parent class.
spec_manifest.jk
class Person {
init(name) {
this.name = name
}
}
class Jack : Person {
func greet() {
println("Hello", this.name)
}
}
let jack = Jack("Jack")
jack.greet()
03
Interfaces
Interfaces enforce structural contracts. Classes implementing an interface use the '@override' decorator to define the required logic.
spec_manifest.jk
interface Greetable {
func greet()
}
class Jack implements Greetable {
@override
func greet() {
println("hello jackal")
}
}
let jack = Jack()
jack.greet()
← Return to Index
Technical Documentation