Skip to content

Instantly share code, notes, and snippets.

@Hoegy
Last active May 25, 2021 23:28
Show Gist options
  • Save Hoegy/f70fb4c778f987c909ca2a62542e7329 to your computer and use it in GitHub Desktop.
Save Hoegy/f70fb4c778f987c909ca2a62542e7329 to your computer and use it in GitHub Desktop.
open class Vehicle {
var make = ""
var model = ""
}
interface LandVehicle
fun Vehicle.cruiseTheBoulevard(): String {
return "cruising the boulevard with my $make $model"
}
class Automobile: Vehicle(), LandVehicle
class Rocket: Vehicle()
fun main(args: Array<String>) {
val myCar = Automobile()
myCar.run { make = "Chevrolet"; model = "Bel Air" }
println("Right now I am: ${myCar.cruiseTheBoulevard()}")
val myRocket = Rocket()
myRocket.run { make = "SpaceX"; model = "Starship" }
println("Right now I am: ${myRocket.cruiseTheBoulevard()}")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment