Dyvil is an object-oriented programming language. And like every other OOP language, it has some notion of Classes. They allow you to group common behavior and properties into one structure that describes objects. The example below displays how a common example, the
Personclass, can be written in Dyvil:
let name: String
let age: int
func greet() -> void = print "Hello, \(name)!"
// constructors omitted
Personclass has two properties, a
nameis a String of characters that holds the name of the person. The
agedescribes how old the person is, in years.
You will also notice the
greetmethod. Given some
person, you can call it like
let person = Person("Peter", 20)
person.greet() // prints "Hello, Peter"
The following chapters will guide you through all the language features related to classes and class members.