Skip to content

Instantly share code, notes, and snippets.

@kalaiselvan369
Created June 9, 2023 05:34
Show Gist options
  • Select an option

  • Save kalaiselvan369/f75b54708c9b7c4daa18a34f2e15e144 to your computer and use it in GitHub Desktop.

Select an option

Save kalaiselvan369/f75b54708c9b7c4daa18a34f2e15e144 to your computer and use it in GitHub Desktop.
Class definition
fun main() {
val dog = Dog()
dog.bark()
}
// class is a user defined data type
class Dog {
// characteristics/properties of a class
val legs: Int = 4
val color: String = "Black"
// member functions
// behavior of a class
fun run() {
// this keyword is a reference to the class or object that this function belongs
this.bark() // bark while running
}
fun bark() {
}
fun sleep() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment