Skip to content

Instantly share code, notes, and snippets.

@dgreenhalgh
dgreenhalgh / SimVillage.kt
Created October 5, 2018 08:58
Big Nerd Ranch Anonymous Functions - SimVillage
fun main(args: Array<String>) {
runSimulation()
}
fun runSimulation() {
val greetingFunction = configureGreetingFunction()
println(greetingFunction("Guyal"))
}
fun configureGreetingFunction(): (String) -> String {
@dgreenhalgh
dgreenhalgh / Jhava.java
Created October 4, 2018 06:05
Big Nerd Ranch Java Interoperability - Jhava
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.util.function.Function;
public class Jhava {
@dgreenhalgh
dgreenhalgh / Hero.kt
Created October 4, 2018 06:02
Big Nerd Ranch Java Interoperability
@file:JvmName("Hero")
import java.io.IOException
fun main(args: Array<String>) {
val adversary = Jhava()
println(adversary.utterGreeting())
val friendshipLevel = adversary.determineFriendshipLevel()
println(friendshipLevel?.toLowerCase() ?: "It's complicated.")