Support for elvis operator.

This commit is contained in:
Pavel V. Talanov
2012-04-02 20:45:36 +04:00
parent 3fbbc71dcb
commit fc683e8141
3 changed files with 47 additions and 5 deletions
@@ -0,0 +1,21 @@
package foo
fun box() : Boolean {
if (f(null) != false) {
return false;
}
if (f(2) != true) {
return false;
}
if (f(1) != false) {
return true;
}
return true
}
fun Int.isEven() = (this % 2) == 0
fun f(a : Int?) : Boolean {
return a?.isEven() ?: false
}