Skip to content

Instantly share code, notes, and snippets.

@hmaurer
Created November 14, 2012 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hmaurer/4072540 to your computer and use it in GitHub Desktop.
Save hmaurer/4072540 to your computer and use it in GitHub Desktop.
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