Permalink
Browse files

Static & Bridge examples

  • Loading branch information...
1 parent 4287f44 commit f8ad414c7971daec6a3918f8139afb8387df9a6c @abreslav committed Oct 2, 2012
@@ -0,0 +1,9 @@
+package _01_intro
+
+fun main(args: Array<String>) {
+ println("abc".last())
+}
+
+fun String.last(): Char {
+ return this[length - 1]
+}
@@ -0,0 +1,15 @@
+package _02_bridges
+
+fun foo(
+ a: Int,
+ b: String = "default",
+ c: String? = null
+) {
+ println(a)
+ println(b)
+ println(c)
+}
+
+fun main(args: Array<String>) {
+ foo(1)
+}
@@ -0,0 +1,11 @@
+package _02_bridges
+
+abstract class WithDefault {
+ abstract fun foo(a: Int = 1)
+}
+
+class ChildWithDefault: WithDefault() {
+ override fun foo(a: Int) {
+ println(a)
+ }
+}
@@ -0,0 +1,5 @@
+package _02_bridges.java;
+
+public class Base<T> {
+ T foo(T t) { return t; }
+}
@@ -0,0 +1,8 @@
+package _02_bridges.java;
+
+public class Child extends Base<Integer> {
+ @Override
+ Integer foo(Integer s) {
+ return s;
+ }
+}
@@ -0,0 +1,9 @@
+package _02_bridges
+
+trait Trait {
+ fun foo() {}
+}
+
+class C: Trait {
+
+}

0 comments on commit f8ad414

Please sign in to comment.