nikolay
02/04/2019, 12:48 PMdG
02/04/2019, 3:51 PMpublic inline fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean {
if (this is Collection && isEmpty()) return false
for (element in this) if (predicate(element)) return true
return false
}
Why is the first if
statement there? Is this for speed reasons?cristiangm
02/05/2019, 10:38 AMcristiangm
02/05/2019, 10:39 AMStrum355
02/05/2019, 4:27 PMSmallville7123
04/15/2019, 6:25 AMclass Stack<T> {
val stack = LinkedList<T>()
fun addLast(value: T) {
stack.append(value)
}
fun push(value: T) {
stack.append(value)
}
fun peek(): T? {
return stack.first()?.value
}
fun pop(): T? {
return stack.removeAtIndex(0)
}
fun test() {
val s = Stack<String>()
s.push("John")
println(s)
s.push("Carl")
println(s)
println("peek item: ${s.peek()}")
println("pop item: ${s.pop()}")
println("peek item: ${s.peek()}")
}
fun contains(s: T?): Boolean = stack.contains(s)
override fun toString(): String = stack.toString()
fun iterator() = stack.iterator()
fun forEach(action: (T?) -> Unit) = stack.forEach(action)
}
Smallville7123
04/15/2019, 6:52 AM// var tokenList: Stack<String> = tokens
// fun clone(): Parser {
// val result = StringBuilder()
// tokenList.forEach {
// result.append(it!!)
// }
// return Parser(parserPrep(result.toString()))
// }
to workSmallville7123
04/15/2019, 7:19 AMSmallville7123
04/15/2019, 7:25 AMSmallville7123
04/15/2019, 7:35 AMSmallville7123
04/15/2019, 11:28 AMorg.jetbrains.kotlin.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type.
issue https://kotlinlang.slack.com/archives/C0922A726/p1555313114099100ribesg
04/15/2019, 1:29 PMSmallville7123
04/15/2019, 1:29 PMprojectmoon
04/15/2019, 3:00 PMkarelpeeters
04/16/2019, 10:34 AMprivate val labelProbArray = Array(1) { FloatArray(256*256) }
jpfarias
04/16/2019, 11:19 AMjpfarias
04/16/2019, 11:20 AMSmallville7123
04/17/2019, 1:42 AMSmallville7123
04/17/2019, 1:45 AMkotlin.test.Test
Smallville7123
04/17/2019, 4:16 AMwhen(it) {
"" -> printHelp()
"-h" -> printHelp()
"--help" -> printHelp()
}
as i currently have thisSmallville7123
04/17/2019, 8:17 AMJM Santos
04/17/2019, 9:43 AMAdrianRaFo
04/17/2019, 9:46 AMZonedDateTime
from java 8 is what I was using and worked fine for meJM Santos
04/17/2019, 9:56 AMAdrianRaFo
04/17/2019, 10:26 AMjoda
is the common option for those cases but 24 support java 8, is up to youstreetsofboston
04/17/2019, 11:42 AMHullaballoonatic
04/17/2019, 7:55 PMfor
, while
, and when
? i'm finding it hard to conceive of why it would be hard for the language to distinguish the conditional from the body, even in inline variations of if
else
Hullaballoonatic
04/17/2019, 7:56 PM