christophsturm
12/19/2018, 12:29 PMRandom
instance? or do i have to store the seed and create it from that again?Ruckus
12/19/2018, 4:43 PMThe companion object Random.Companion is the default instance of Random.But isn't the companion object
Random.Default
?Ruckus
12/19/2018, 5:21 PMoperator fun contains
object Links {
<values here>
operator fun contains(link: String) = when (link) {
HELP, SHOP, BLOG, ... -> true
else -> false
}
}
Tasos Stamadianos
12/19/2018, 8:49 PMtry-catch-null-check.kt:22:24: error: operator call corresponds to a dot-qualified call 'nullableVal.plus(1)' which is not allowed on a nullable receiver 'nullableVal'.
val sum = nullableVal + 1
^
ghedeon
12/19/2018, 9:07 PM::
(bound callable reference?). Any way to properly import Companion
so I don't see it in the code?
class Foo(bar: () -> Bar)
class Bar {
companion object {
fun newInstance() = Bar()
}
}
....
Foo(Bar.Companion::newInstance) //<--- works
Foo(Bar::newInstance) //<--- doesn't work
Dominaezzz
12/19/2018, 9:11 PMCollection<...>
. The only difference is one is on Collection<String>
and the other is Collection<Closeable>
. IntelliJ complains they have the same signature on JVM (because type erasure). Even though they are inline functions?jdemeulenaere
12/19/2018, 9:54 PMDalinar
12/20/2018, 9:54 AMDias
12/20/2018, 10:54 AMwhen
expression for example becomes non-exhaustivekarelpeeters
12/20/2018, 10:55 AMreik.schatz
12/20/2018, 11:57 AMArray<String>?
and a String?
and I need to merge the two and return Array<String>?
- is there a better way than to have a bunch of if-else checking for null
(if both are null it should return null also)?ribesg
12/20/2018, 12:32 PMClass<Map<String, Any>>
without creating an empty map?xenoterracide
12/20/2018, 1:00 PMIlias Yahia
12/20/2018, 2:10 PMRuckus
12/20/2018, 8:39 PMAny
paulex
12/21/2018, 1:53 AMDalinar
12/21/2018, 6:39 AMMarcelo Velloso
12/21/2018, 2:36 PMhhariri
12/21/2018, 3:01 PMtschuchort
12/21/2018, 4:29 PMK2JVMCompiler
) and noticed that I can compile files using the java.*
packages even if the option -no-jdk
is used. How can that happen? Surprisingly it works if the host project JDK is version 9 but not with version 8, even though it shouldn't make a difference since the compiler doesn't have access to the host process' classpath (and doesn't log loading any jdk modules as it normally would)Dalinar
12/21/2018, 6:01 PMList
returned by val lines = reply.split("\n")
?Strum355
12/21/2018, 6:02 PMgroostav
12/21/2018, 7:54 PMfun `kotlin is pretty smart`(){
val nullableSet: Set<Int>? = setOf(1, 2, 3)
when(nullableSet?.size){
null -> {}
else -> { nullableSet.first() }
}
}
I would've thought that I'd need a nullableSet!!
in the second case.
does that mean the smart-cast system was able to infer that
well the expressionif so, that kotlinc is one sharp cookiewasn't null, andnullableSet?.size
can never be null, sosize
must also not be null, so I can smart-cast it tonullableSet
Set<Int>
Ruckus
12/21/2018, 10:47 PMclass Ref<T: Ref<T>> { ... }
class RefHolder<T: Ref<T>> { ... }
class Source {
val refs: MutableList<RefHolder<*>> = ...
...
}
fun <T: Ref<T>> serializeRef(ref: RefHolder<T>, ...): ... { ... }
fun serializeSource(source: Source): ... {
val refs = source.refs.map { serializeRef(it, ...) } // Cannot resolve type as it: Ref<*>
}
How do I make it so I can call serializeRef
?Ruckus
12/21/2018, 10:56 PMserializeRef(it as RefHolder<Nothing>, ...)
which works due to erasure, but it feels wrong and dirty.Will Harrison
12/21/2018, 11:00 PMentries
and wanted to create another list from entries
by running each item through a method to do some conversions, could I do it using the list.map{ ... }
function or do I just need to loop through and add each one individuallyJohan Vergeer
12/22/2018, 1:11 PMotakusenpai
12/22/2018, 1:31 PMotakusenpai
12/22/2018, 1:32 PMJohan Vergeer
12/22/2018, 5:08 PMJohan Vergeer
12/22/2018, 5:08 PMkarelpeeters
12/22/2018, 6:06 PM