Javier
08/18/2020, 11:22 PM-common
to implement them?Joseph Magara
08/18/2020, 11:51 PMVampire
08/19/2020, 3:02 AMinline fun <reified T> options(options: T.() -> Unit): T = object : T {}.apply(options)
?lib
08/19/2020, 3:13 AMPaul Woitaschek
08/19/2020, 9:27 AMOrhan Tozan
08/19/2020, 9:46 AMPablo
08/19/2020, 9:55 AMwaltermcq
08/19/2020, 1:22 PMLqncer
08/19/2020, 3:38 PMcolintheshots
08/19/2020, 5:05 PMtoBoolean(): Boolean' is deprecated. Use Kotlin compiler 1.4 to avoid deprecation warning.
It seems like this is not a well-functioning deprecation warning. There's no easy way to select the String?.toBoolean() version instead. Even if I cast to String?, the 1.4 compiler won't let me call String?.toBoolean() explicitly. It seems like a compiler bug.Mark Buikema
08/20/2020, 10:08 AMsealed class PaymentMethod {
abstract val transactionCost: BigDecimal
data class PayPal(...) : PaymentMethod
data class CreditCard(...) : PaymentMethod
data class Cash(...) : PaymentMethod
companion object {
fun create(id: Long, transactionCost: BigDecimal) : PaymentMethod {
// TODO
}
}
}
Also I want to have a single source of truth for defining which ID belongs to which subclass (only define it once).
Would like to hear some tips on how to implement this. If you think there are better approaches (except for modifying API) than what I want, feel free to suggest.Esa
08/20/2020, 10:53 AMAnimesh Sahu
08/20/2020, 11:29 AMPhani Mahesh
08/20/2020, 3:28 PMKarlo Lozovina
08/20/2020, 6:26 PMKarlo Lozovina
08/20/2020, 6:28 PMedrd
08/20/2020, 7:22 PMalwyn
08/20/2020, 8:50 PMfun calculateNumberOfLengthBytes(data: ByteArray): Int {
val l: Int = data.size
return when {
l < 128 -> 1
l < 16384 -> 2
l < 2097152 -> 3
l < 268435456 -> 4
else -> 5
}
}
but, the following complains about "Incompatible types: Boolean and Int" in the comparisons
val data = byteArrayOf(5, 6, 7)
when(val l: Int = data.size) {
l < 128 -> 1
l < 16384 -> 2
l < 2097152 -> 3
l < 268435456 -> 4
else -> 5
}
xii
08/20/2020, 11:41 PMeygraber
08/21/2020, 1:49 AMmax
on. I get a deprecation warning, so I run the "Replace with maxOrNull" fix, and it replaces .max()
with maxOrNull()
. So I put the .
in front, and I get an unresolved reference error. There is no fix to import it. So I manually write the import (import kotlin.sequences.maxOrNull
), and I still get the unresolved reference error, and the import is gray (unused)._Sequences.kt
I see public fun <T : Comparable<T>> Sequence<T>.maxOrNull(): T?
kevin.cianfarini
08/21/2020, 3:30 AM@Fork(1)
@Warmup(iterations = 5, time = 2)
@Measurement(iterations = 5, time = 2)
@State(Scope.Benchmark)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
open class Sha1Benchmark {
}
produces the corresponding error?
> Task :okio:jvm:jmh:jmhRunBytecodeGenerator FAILED
Processing 15 classes from /home/kevin/code/okio/okio/jvm/jmh/build/classes/java/jmh with "reflection" generator
Processing 2 classes from /home/kevin/code/okio/okio/jvm/jmh/build/classes/kotlin/jmh with "reflection" generator
Writing out Java source to /home/kevin/code/okio/okio/jvm/jmh/build/jmh-generated-sources and resources to /home/kevin/code/okio/okio/jvm/jmh/build/jmh-generated-resources
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':okio:jvm:jmh:jmhRunBytecodeGenerator'.
> A failure occurred while executing me.champeau.gradle.JmhBytecodeGeneratorRunnable
> Generation of JMH bytecode failed with 1 errors:
- Benchmark classes should not be final.
[com.squareup.okio.benchmarks.Sha1Benchmark]
frank
08/21/2020, 4:43 AMjava.nio
in Kotlin and I have a question:
Why don't work member references
to function is this case? *I know that with Files.isDirectory(it)
work i*t
val stream = Files.list(folder)
val files = stream.filter { it != null && Files::isDirectory } // error in Files::isDirectory
.map { it!! }
Error Msg:
Type mismatch.
Required: Boolean
Found: KFunction2<Path!, Array<(out) LinkOption!>!, Boolean>PD: Sorry, if this topic doesn't have to be in this channel, but I didn't find JVM channel.
Vampire
08/21/2020, 9:44 AMSequence#map
lambda?
Or if not, is there some other construct to achieve the result?Srki Rakic
08/21/2020, 1:20 PMSam Garfinkel
08/21/2020, 2:51 PMMutableList<>
property with a getter that returns it as a List<>
?xii
08/21/2020, 2:55 PMKarlo Lozovina
08/21/2020, 5:04 PMwhen
expression? something like Haskell can do, like (Foo (Bar (Baz x))) -> ... something(x)
?Philipp Mayer
08/21/2020, 7:52 PMGunslingor
08/22/2020, 3:09 AM".clearfix" { clear = Clear.both }
in browser becomes
clearfix { clear = both }
So confused. It works elsewhere, but this is like another layer of css in.Mehdi Haghgoo
08/22/2020, 7:55 AMMehdi Haghgoo
08/22/2020, 7:55 AMYaroslav Chernyshev [JB]
08/22/2020, 8:01 AMCmd + Shift + A
shortcutNikky
08/22/2020, 9:26 AMBen Woodworth
08/22/2020, 6:36 PMHelp
menu