Classes in Silicon are equivalent to classes in other languages such as Java, Kotlin, and C# in that they are object definitions which can contain functions and variables. They are declared with the class keyword, followed by the name and curly brackets to contain all of the class's variables and functions:
class Foo {
var x : Int;
func doFooThing() {
}
}
Constructors
Class constructors in Silicon are special functions which return a new instance of the class. They are declared with the constructor keyword and written like so:
class Bar {
var x : Int;
constructor(x : Int) {
self.x = x
}
Overview
Classes in Silicon are equivalent to classes in other languages such as Java, Kotlin, and C# in that they are object definitions which can contain functions and variables. They are declared with the
class
keyword, followed by the name and curly brackets to contain all of the class's variables and functions:Constructors
Class constructors in Silicon are special functions which return a new instance of the class. They are declared with the
constructor
keyword and written like so:Inheritance
Virtual Methods and Fields