Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bruce Eckel
committed
Nov 24, 2017
1 parent
287fa95
commit c72e4cf
Showing
13 changed files
with
75 additions
and
14 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// FromKotlin/NullableJavaTool.java | ||
package FromKotlin; | ||
|
||
public class NullableJavaTool { | ||
public static NullableJavaTool get() { | ||
return null; | ||
} | ||
public void method() {} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// FromKotlin/UseNullableJavaTool.kt | ||
import FromKotlin.NullableJavaTool | ||
import atomictest.* | ||
|
||
fun main(args: Array<String>) { | ||
val a = NullableJavaTool.get() | ||
capture { | ||
val b: NullableJavaTool = | ||
NullableJavaTool.get() | ||
} eq "IllegalStateException" | ||
val c: NullableJavaTool? = | ||
NullableJavaTool.get() | ||
capture { | ||
a.method() | ||
} eq "NullPointerException" | ||
c?.method() eq null | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
// WhenExpressions/WhenAsStatement.kt | ||
import atomictest.* | ||
|
||
fun checkColor(color: String) { | ||
when (color) { | ||
"red" -> println("RED") | ||
"blue" -> println("BLUE") | ||
"green" -> println("GREEN") | ||
when(color) { | ||
"red" -> trace("RED") | ||
"blue" -> trace("BLUE") | ||
"green" -> trace("GREEN") | ||
} | ||
} | ||
|
||
fun main(args: Array<String>) { | ||
checkColor("white") | ||
checkColor("blue") | ||
trace eq "BLUE" | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//package jhelper; | ||
public class JHelper { | ||
public static JHelper jF() { return null; } | ||
public void M() {} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import jhelper.* | ||
fun main(args: Array<String>) { | ||
val a = JHelper.jF() | ||
a.M() //Oops! | ||
} |
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