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
val reference = KotlinFilterOperation()::filterBy |
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
public class JavaUser { | |
// ... | |
public static Set<String> fetchCitiesOfUsers( | |
List<JavaUser> users) { | |
return users.stream() | |
.flatMap(user -> user.addresses.stream()) | |
.map(JavaUser.Address::getCity) | |
.collect(Collectors.toSet()); |
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
fun fetchCitiesOfUsers(users: List<KotlinUser>) = users | |
.flatMap(KotlinUser::addresses) | |
.map(Address::city) | |
.toSet() |
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
public class KotlinInterop { | |
public void helloJava() { | |
System.out.println("Hello from Java!"); | |
} | |
public void helloKotlin() { | |
JavaInterop.createInstance().helloKotlin(); | |
} | |
} |
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
class JavaInterop { | |
fun helloJava() { | |
KotlinInterop().helloJava() | |
} | |
fun helloKotlin() { | |
println("Hello from Kotlin!") | |
} |
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
class Foo { | |
private val c: String | |
init { | |
bar() | |
c = "" | |
} | |
private fun bar() { | |
println(c.length) | |
} | |
} |
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
val map = ConcurrentHashMap<String, String>() | |
map["foo"] = "bar" | |
val bar: String = map["foo"]!! |
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
val queue: Queue<String> = LinkedList() | |
queue.peek().toInt() |
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
/** | |
* Retrieves, but does not remove, the head of this queue, | |
* or returns {@code null} if this queue is empty. | |
* | |
* @return the head of this queue, or {@code null} if this queue is empty | |
*/ | |
E peek(); |
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
val queue: Queue<String?> = LinkedList() | |
queue.peek()?.toInt() |