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
package x | |
fun fn(items: List<String?>) { | |
items.foreach(filter.notNull) { value -> | |
println("$value") | |
} | |
items.foreach(map.indexed) { (index,value) -> | |
println("$index $value") | |
} |
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
trait SelectResult<T> { | |
val take: Boolean | |
val value: T | |
class object { | |
fun take<T>(value: T) = object : SelectResult<T> { | |
override val value: T = value | |
override val take: Boolean = true | |
} | |
fun skip<T>() = object : SelectResult<T> { |
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 String.pluralize() : String{ | |
val rules = listOf( | |
"$" to "s", | |
"s$"to "s", | |
"(ax|test)is$" to "$1es", | |
"us$" to "i", | |
"(octop|vir)us$" to "$1i", | |
"(octop|vir)i$" to "$1i", | |
"(alias|status)$" to "$1es", | |
"(bu)s$" to "$1ses", |
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
/** | |
* Disclamer: This is sort of a rant, but without any negative feelings towards the creators of the project | |
* in question. | |
* I value their desire to help people write more readable code, and wish there were more people doing this! | |
* The only thing I'm questioning is the ever growing trend of tools over craft. | |
* | |
* This is a mini blog-post in response to https://twitter.com/hhariri/status/435457449232171008 | |
* | |
* The reason I have some negative feelings is that writing readable code is not rocket | |
* science, and with tools like Spek, we're basically allowing people to be ignorant about crafting clean |