arnaud.giuliani
12/06/2017, 3:02 PMGauthierPLM
12/06/2017, 4:46 PMjoshua.ewer
12/06/2017, 7:19 PMgiven two nullable lists,anda: List<String>?
b:List<String>?
if any are not null, return a concat list
else return null
elizarov
12/06/2017, 7:29 PMb?.let { a?.plus(it) ?: it } ?: a
to return null only if both are nullbj0
12/06/2017, 7:30 PM?: it
joshua.ewer
12/06/2017, 7:48 PMjmfayard
12/06/2017, 7:58 PMjtonic
12/07/2017, 6:05 AMError:(13, 30) Kotlin: Type checking has run into a recursive problem. Easiest workaround: specify types of your declarations explicitly
in the following case
package ro.jtonic.tutorials.kt.oop.miscs
private const val PI = Math.PI
const val E = Math.E
private fun computePi() = PI
fun computeE() = E
class MyMath {
val E = FilePrivateUtils@::E.get() // here is the compilation error
val pi = FilePrivateUtils@::PI.get()
fun computingPi() = FilePrivateUtils@::computePi.invoke()
fun computingE() = FilePrivateUtils@::computeE.invoke()
}
Thank you.Ruckus
12/07/2017, 4:46 PMcedric
12/07/2017, 6:42 PMdata class Foo(var s: Int? = null)
, is it possible to invoke the default constructor by reflection without requiring @JvmOverloads
? Without it, I see that this class has two constructors, one with a last parameter DefaultConstructorMarker
but it doesn’t look like I can invoke it.adams2
12/07/2017, 7:10 PMThiago
12/07/2017, 8:02 PMemmanuelvinas
12/08/2017, 9:03 AMmichaelzinn
12/08/2017, 10:27 AMmichaelzinn
12/08/2017, 10:52 AMx?.let { bla(it) }
becomes let(x, Bla::bla)
for example.karelpeeters
12/08/2017, 11:53 AMwhen
and for
statements, where it has a slightly different meaning.Thiago
12/08/2017, 2:19 PMnickk
12/08/2017, 3:30 PMdata class ResultWrapper<out T>(val request: RequestInfo, val obs: T, val typeOfResult : KClass<*>? = null)
However doing a when
on the typeOfResult
field does not work:
when (item.typeOfResult) {
is Enemy -> {
messages.add("Received instance of type ${item.typeOfResult.simpleName} !")
}
Any ideas/suggestions?evan
12/08/2017, 10:20 PMval byteVal:Byte = 0
val isZero = byteVal == 0
You have to change it to this to make it compile (and run):
val byteVal:Byte = 0
val isZero = byteVal == 0.toByte()
This seems overly complicated to just compare a byte-value with a literal. Do we really have to call a method (toByte()
) to do this?
Is there a modifier (much like L
for longs and f
for floats) to make this simpler and less expensive?karelpeeters
12/09/2017, 8:57 PMmc
12/10/2017, 1:12 PMclass Example {
private val backingMap = mutableMapOf<String, MutableSet<String>>()
fun addVertex(v: String): Boolean = backingMap.putIfAbsent(v, mutableSetOf()) == null
fun addEdge(v: String, w: String): Boolean {
listOf(v, w).map(::addVertex)
return backingMap[v]!!.add(w)
}
}
robfletcher
12/10/2017, 7:29 PMfun <ACTUAL> expect(
actual: ACTUAL,
block: ObjectAssert<ACTUAL>.(ACTUAL) -> Unit
): ObjectAssert<ACTUAL>
and fun <ELEMENT> expect(
actual: List<ELEMENT>,
block: SoftAssertionListAssert<ELEMENT>.(List<ELEMENT>) -> Unit
): SoftAssertionListAssert<ELEMENT>
that the compiler is unable to distinguish between at the call site. I get why that’s an issue but confusingly I have overloads of both that only accept the first parameter: fun <ACTUAL> expect(actual: ACTUAL): AbstractObjectAssert<*, ACTUAL>
and fun <ELEMENT> expect(actual: List<ELEMENT>): ListAssert<ELEMENT>
that the compiler can distinguish. Can anyone enlighten me as to why one is a problem and no the other? Is there any way I can disambiguate the 2 param form?pakoito
12/10/2017, 8:41 PMMarcin Wisniowski
12/11/2017, 6:06 AMmap
or pass a method reference:
listOf("1", "2", "3").map { it.toInt() }
listOf("1", "2", "3").map(String::toInt)
Is either of these considered better? (Or am I overthinking this?)karelpeeters
12/11/2017, 8:45 AM\n
. str.split("\n").map { it.split("\t").map { it.toInt() } }
edwardwongtl
12/11/2017, 10:34 AMSlackbot
12/11/2017, 1:00 PMlovis
12/11/2017, 1:11 PMpublic
instead of internal
when the visibility was package-private
before? 🤔EDesigner250
12/11/2017, 2:06 PMstkent
12/11/2017, 4:13 PMfold
and access the intermediate values?stkent
12/11/2017, 4:13 PMfold
and access the intermediate values?ilya.gorbunov
12/11/2017, 6:32 PMstkent
12/11/2017, 6:38 PM