karelpeeters
11/07/2018, 8:05 PMKotlin protects you from mistakenly operating on nullable types
fun foo(): String {
null?.let {
return it
}
}
println(foo().length) //NullPointerException
Kevin Huang
11/08/2018, 2:25 AMgoto
.
And in lambdas,can't call "return" directly. In some complex cases , can't return a value immediately , need some ugly code to solve.
Any suggests for this situation?
Thanks.stevecstian
11/08/2018, 2:49 AMcygnus
11/08/2018, 3:51 AMMassimo Carli
11/08/2018, 11:24 AMString::class
is KClass<String>
while the type of "Hello"::class
is KClass<out String>
? This means that what "Hello"::class
returns is a KClass<T>
where T
is a subtype of String
. But String
is final and it doesn't have subtypes. 🤔bartvh
11/08/2018, 2:44 PMgetValue(receiver, property)
method. While that's true, I only have a var value: Boolean
, I've looked into the source code for Lazy an it also only has a var value: T
. Why can't I do it like this in my custom class?vkuznetsov
11/08/2018, 3:28 PMMassimo Carli
11/08/2018, 3:29 PMString?
arekolek
11/08/2018, 3:39 PMvkuznetsov
11/08/2018, 3:40 PMdagguh
11/08/2018, 3:58 PMInheritance from an interface with ‘@JvmDefault’ members is only allowed with -Xjvm-default option
I tried Googling and searching in this Slack, but came up short.
I understand why the interface compilation needs this flag. But why do the implementations need this flag too? Can't the compiler see that the interface is compiled on JVM target 8 and uses the default
Java 8 in the method and simply compile as if you implemented in Java?
Here's a concrete incarnation of this problem: https://ecosystem.atlassian.net/browse/JPERF-260igor.wojda
11/08/2018, 5:47 PMCharSequence.reduce
function?marcelo
11/08/2018, 7:47 PMFile.copyTo
and setting overwrite = true
it still throws a FileAlreadyExistsException
. I check the file permissions and so far can't write nor can't read. Is there anything that I can do to force a file to be updated? I tried deleting but nope.jlleitschuh
11/08/2018, 10:01 PMcamkadev
11/09/2018, 10:08 AMBillKarv
11/09/2018, 10:12 AMjmfayard
11/09/2018, 11:03 AMigor.wojda
11/09/2018, 11:54 AMlist.subList()
2nd param toIndex
is not end inclusive 🤔
//have
val list = listOf(1,2,3,4)
//want sublist
listOf(3,4)
dalexander
11/09/2018, 3:54 PMcoder82
11/09/2018, 5:19 PMcoder82
11/09/2018, 5:21 PMcoder82
11/09/2018, 6:05 PMigor.wojda
11/09/2018, 6:45 PMconst matches = str.match(/[aei]/gi)
to check if string contains a
, e
or i
character. However In kotlin this does not work. I wonder are the regular expression general cross-language concept or each language has own implementation (similar to other languages yet different)?jeggy
11/09/2018, 6:53 PMout
?Alowaniak
11/09/2018, 7:36 PMlongArray.toList().groupingBy{ it }.eachCountTo(sortedMapOf())
?Marcel Overdijk
11/09/2018, 9:11 PMdharrigan
11/09/2018, 9:26 PMkevinherron
11/10/2018, 12:17 AMchansek
11/10/2018, 11:38 AMBernhard
11/10/2018, 4:15 PMBernhard
11/10/2018, 4:15 PMBirneee
11/10/2018, 4:21 PMigor.wojda
11/10/2018, 4:26 PMBernhard
11/10/2018, 4:26 PMigor.wojda
11/10/2018, 4:36 PMdynamic
type (I know it’s far from perfect) https://kotlinlang.org/docs/reference/dynamic-type.htmlBernhard
11/10/2018, 4:39 PMthanksforallthefish
11/10/2018, 4:39 PMHamza
11/10/2018, 10:00 PM