Created
November 14, 2012 14:47
-
-
Save hmaurer/4072540 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.util.* | |
abstract class LivingThingy(val age : Int) { | |
} | |
trait Badass { | |
public fun bark() { | |
println("Wouf wouf!") | |
} | |
} | |
class Puppy(name : String) : LivingThingy(12), Badass { | |
var name : String = "Unknown" | |
get() = $name; | |
set(value) { | |
$name = value | |
} | |
{ | |
this.name = name | |
} | |
public fun sayHello() { | |
println("Hello! My name is ${this.name}.") | |
} | |
} | |
fun sayHello(callback : () -> Unit) : Unit { | |
callback(); | |
} | |
fun register<T : Any>(module : T) { | |
println("Registering module...") | |
} | |
fun main(args: Array<String>) { | |
sayHello({() -> println("Hello world!")}); | |
register<String>("abc"); | |
var puppies : List<Puppy> = ArrayList<Puppy>(); | |
puppies.add(Puppy("Rex")) | |
for (puppy in puppies) { | |
println(puppy is LivingThingy); | |
puppy.bark(); | |
puppy.sayHello(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment