Skip to content

Instantly share code, notes, and snippets.

View prestongarno's full-sized avatar

Preston Garno prestongarno

View GitHub Profile
prestongarno / puzzler.kt
Last active May 19, 2018 17:57
What is the output of this program?
import kotlin.reflect.KProperty
class ResponsibleDelegate<out T>(initializer: () -> T?) {
private val value by lazy(initializer)
operator fun getValue(thisRef: Any?, property: KProperty<*>): T =
value ?: throw NullPointerException()
fun parsePhoneNumber(text: String): PhoneNumber {
val destructuredRegex = "([0-9]{3})-([0-9]{3})-([0-9]{4})".toRegex()
return destructuredRegex.matchEntire(text)
?.let { (areaCode, prefix, lineNumber) ->
PhoneNumber(areaCode.toInt(), prefix.toInt(), lineNumber.toInt())
import java.nio.file.*;
import java.nio.file.spi.FileSystemProvider;
import java.util.*;
import java.util.function.Function;
import javax.swing.*;
public class CustomFileChooser {