gabin
11/21/2018, 11:51 AModay
11/21/2018, 2:20 PMelse
of a when
include all possible values of the variable that are not mentioned in the when?oday
11/21/2018, 2:20 PMageery
11/21/2018, 9:41 PMfun <C: Any, T: C?> List<T>.nonNull(sub: C) = map { it ?: sub }
. However, the compiler can't infer the type of C if there is a null in the list. For example, this doesn't compile: val x = listOf("x", null).nonNull("y")
. You have to explicitly specify the types: val x = listOf("x", null).nonNull<String, String?>("y")
. Is there something wrong with my method signature that prevents the compiler from inferring the types?henrik
11/22/2018, 8:56 AMfun toMap(): Map<String, Double> = mapOf("key" to nullableDouble1, "key2" to nullableDouble2).filterValues { it != null }
complains that "expected Map<String, Double>
but found `Map<String, Double?>`". Is there an easy way around this other than appending as Map<String, Double>
?Sartori
11/22/2018, 4:44 PMjojo.lichtenberger
11/24/2018, 1:50 PMdewildte
11/24/2018, 7:57 PMlet {}
is kinda cryptic.jschneider
11/24/2018, 7:59 PMliminal
11/25/2018, 6:27 PMtakeIf {}
elye
11/26/2018, 6:37 AM(origin as? Implementor)?.someFunction()
vs
(origin as Implementor?)?.someFunction()
febs
11/26/2018, 12:50 PMdG
11/26/2018, 3:36 PMfoo(first : SomeObj = validSomeObj()) : Bar = foo(first.toString())
foo(first : String = validSomeObj().toString()) : Bar = Bar(first)
looks like thisserebit
11/26/2018, 6:07 PMQuy D X Nguyen
11/27/2018, 4:18 AMelect
11/27/2018, 8:46 AMbuildscript
section?liminal
11/28/2018, 3:39 AMclaudiug
11/28/2018, 11:21 AMSlackbot
11/28/2018, 11:31 AMNarayan Iyer
11/28/2018, 4:44 PMfun <T> head(ls: List<T>): List<T> = ls.get(0)
error: type mismatch: inferred type is T but List<T> was expected
fun <T> head(ls: List<T>): List<T> = ls.get(0)
^
stephan_marshay
11/28/2018, 4:49 PMval<T> List<T>.head: T
get()= this[0]
Narayan Iyer
11/28/2018, 4:49 PMfun <T> tail(ls: List<T>): List<T> {
return ls.drop(1)
}
why is it insisting on the return
statement?!stephan_marshay
11/28/2018, 4:50 PMList<T>
)hudsonb
11/28/2018, 5:18 PMrun
needed there?nekomatic
11/29/2018, 10:44 AMtipsy
11/29/2018, 6:19 PMPair(str.split(Regex(" "), 2)[0], str.split(Regex(" "), 2)[1])
, i could also use indeces.. is there a more elegant way?dMusicb
11/29/2018, 6:40 PMfor (i in (1..10)) {
// do stuff
someFunc() // inside someFunc call continue to skip below part
// do other stuff
}
ursus
11/30/2018, 2:06 AMSlackbot
11/30/2018, 12:26 PMfebs
12/01/2018, 6:32 PMfebs
12/01/2018, 6:32 PMhudsonb
12/01/2018, 6:45 PMreturn
behaviorkarelpeeters
12/02/2018, 12:16 PM