pawel.rybicki
09/03/2019, 3:55 PMRafa
09/03/2019, 11:55 PMclass Example<T>(private val source: T){
fun test(value: T?): T? = value
}
fun <T> create() = Example(null)
If we define the class to take in a non-nullable generic type, and still pass in null, Example(null)
then the generic resolves to Example<Nothing?>
. If we make the generic nullable T?
then it resolves to Example<Nothing>
.
I can't find anything online that confirms that null on a generic type returns "Nothing" and I guess it kind of make sense, but can anyone confirm as to how that happens?qasim majeed
09/04/2019, 7:45 AMSaurav Kothari
09/04/2019, 8:02 AMKotlinMapper
to cast an SQL Date
column to Kotlin Date
. Would appreciate any help I can get!Jakub
09/04/2019, 9:36 AMvar listener: (()->Unit)? = null
. In kotlin I would pass it like mCircleShape.listener = {}
but how to pass it from Java
?Slackbot
09/04/2019, 9:44 AMLastExceed
09/04/2019, 10:59 AMrunBlocking {
try {
val listener = aSocket(ActorSelectorManager(<http://Dispatchers.IO|Dispatchers.IO>)).tcp().bind(InetSocketAddress(12345))
val socket = listener.accept()
println("client connected")
socket.openReadChannel().readInt()
}
catch (ex: Throwable) {
println("client disconnected")
}
}
when i connect to this and then disconnect it throws a `CancellationException`which is caused by an IOException
. More specifically, it is thrown in readInt()
because it's trying to read data from a closed stream. I know i can and should only catch that specific exception at that specific line, but for the example code i wrapped the entire thing in catch Throwable to make double sure it catches everything.
But even though I catch it and the catch block is executed just fine the exception is still thrown into the console. why is that?asad.awadia
09/05/2019, 1:57 AMShootingStar
09/05/2019, 8:17 AMcoder82
09/05/2019, 10:00 AMAdrian M
09/05/2019, 12:38 PMdgleeson
09/05/2019, 7:05 PMclass KotlinWebService @Inject constructor(configuration: KotlinServiceConfiguration) : WebService(configuration.webServerPort, configuration.oidcBaseUrl)
that has mostly been working as expected. The problem I have is when I try to do something to the super during the init. e.g. init { super.setUnauthorizedUrls(setOf("/path")) }
I get java.lang.UnsupportedOperationException
. It seems like init is happening before injection. Does anyone have any ideas?Toddobryan
09/06/2019, 12:06 AMkotlin.String
, <http://kotlin.to|kotlin.to>
, and kotlin.with
that should not need to be imported. Both my colleague and I are noticing this . Is it just us and is there a way to stop this madness?jmfayard
09/06/2019, 7:42 AMSomeImportantApiClass.java
, is it possible to declare in java a empty Companion
object so that Kotlin users of the library can define their extension on fun SomeImportantApiClass.Companion.someExtension()
?Mahendran
09/06/2019, 10:25 AMjfburdet
09/06/2019, 2:35 PMSam Schilling
09/06/2019, 4:29 PMGopal S Akshintala
09/07/2019, 3:02 PMdownTo
variant to exclude last item like until
?karelpeeters
09/08/2019, 6:37 PMinline fun foo(block: (() -> Unit)?) {
block?.invoke()
}
Inline parameter [...] must not be nullable. Add 'noinline' modifier to the parameter declaration or make its type not nullable
Why? Would there be a problem compiling something like that? I can't imagine why.
Interestingly you can suppress this, @Suppress("NULLABLE_INLINE_PARAMETER")
but that does't actually inline the lambda, and the IDE doesn't suggest that.PHondogo
09/09/2019, 8:15 AMfun <T> test(v: T, lambda: (T) -> Unit ) {
lambda(v)
}
And at call site i have code :
val lambda = {v : Any -> println(v)}
test<SomeObject>(SomeObject(), lambda)
The code below wont compile, cause compiler want to have my val lambda have parameter type exact as declared in function.
How should I modify my fun test declaration to allow <in Parameter> in lambda parameter?alexey.sedunov
09/09/2019, 10:11 AMMark Buikema
09/09/2019, 10:16 AMgroupBy
, is there any nice and easy way to sort the items within the groups?BugsBunny
09/09/2019, 1:05 PMJuanoterocas
09/09/2019, 10:14 PMif(x!=null && x.name.equals("name"))
{}
first evaluate if x is not null then second condition, second condition is not checked if x is null and then is false since && operator only true when all its true, must stop evaluating second condition, is this by desing? how could I do this in kotlin?Mahendran
09/10/2019, 6:39 AMDaniele Segato
09/10/2019, 9:44 AMfield
, of course he force me to initialize
Why does the compiler force me to initialize a variable that is never actually read?
the get()
doesn't ever expose the actual value of entries
but if I do not include = null
it complain with property must be initialized
I might be wrong but I kinda remember it didn't worked like that a couple of months ago (previous versions)Mahendran
09/10/2019, 10:56 AMjanvladimirmostert
09/10/2019, 10:59 AMcoder82
09/10/2019, 1:06 PMnimtiazm
09/10/2019, 2:15 PMnimtiazm
09/10/2019, 2:15 PMadamd
09/10/2019, 3:30 PMAny
?nimtiazm
09/10/2019, 3:49 PMCStage<T, U, N: CStage<U, *, N>>
i can’t use any other CStage for NKroppeb
09/10/2019, 8:32 PMnimtiazm
09/11/2019, 7:44 AMKroppeb
09/11/2019, 8:35 AMRuckus
09/11/2019, 3:23 PM