Last active
May 25, 2021 23:28
-
-
Save Hoegy/f70fb4c778f987c909ca2a62542e7329 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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