Bernhard
01/17/2019, 2:01 PMBernhard
01/17/2019, 2:01 PMBernhard
01/17/2019, 2:01 PMBernhard
01/17/2019, 2:02 PMarve
01/17/2019, 2:03 PMarve
01/17/2019, 2:04 PMctrl+j
on the function, it shows you the inferred return typeShreyas Patil
04/30/2020, 8:06 AMuser
04/30/2020, 3:30 PMuser
04/30/2020, 9:33 PMMari
05/01/2020, 6:02 AMmathew murphy
05/01/2020, 3:59 PMat foo.bar.Task.run(FileName.kt:351)
when the file only has 319 lines.Ahmed Mourad
05/02/2020, 3:54 PMjava.lang.NullPointerException
to be thrown.
Shouldn't the compiler recognize that crash
is modifying the property before it's assigned?iex
05/03/2020, 12:37 PMupdate
on MessageDigest
like this append or overwrite the data?
val digest = MessageDigest.getInstance("SHA-256")
digest.update("foo".toByteArray())
digest.update("bar".toByteArray())
I see in the source that update
calls engineUpdate(input, 0, input.length);
, which:
/**
* Updates the digest using the specified array of bytes,
* starting at the specified offset.
*
This makes me thing that it overwrites the data, but the first snippet seems to work, so I'm confusedAnimesh Sahu
05/04/2020, 4:50 AMMemberVisibilityCanBePrivate
and unused
Im currently doing that by putting this in every file:
@file:Suppress("MemberVisibilityCanBePrivate", "unused")
Is there any way to do this, like we do for experimental apis and opt-ins using gradle compilation args or something.zvozin
05/04/2020, 8:29 PMkotlin.String
from Java?
Trying to set a package-wide Hibernate type mapping default for String
to PG text
@TypeDef(name = "string", defaultForType = String::class, typeClass = TextType::class)
zvozin
05/04/2020, 8:30 PMpackage-info.java
doesn't, presumably because it doesn't think of Kotin strings as Java strings.user
05/05/2020, 9:30 AMShahumang8
05/05/2020, 10:02 AMSebastien Leclerc Lavallee
05/06/2020, 3:12 AMinterface ApiMessage<T : ApiMessage<T>> {
fun convertToBytes(): ByteArray
}
data class GetAllMessagesRequest(): ApiMessage<GetAllMessagesRequest> {
}
And later in my code I want to do something like:
fun performRequest(request: ApiMessage)
But the compiler complain about One type argument expected for T
How could I achieve something like this and received a generic instance of my interface? I can’t really easily change my ApiMessage
interface and request message.
Thanks!Ivan Brko
05/06/2020, 2:50 PMmiqbaldc
05/06/2020, 5:54 PM// option 1
@SafeGetter // custom annotation
val list: MutableList<String> = emptyList()
// option 2 - custom class
class SafeMutableList<E> : MutableList<E> {
@SafeGetter
override fun get(index: Int) = super.get(index)
}
val list: SafeMutableList<String> = emptyList()
1. compile-time error
if (list.get(7)) { // when running/building this code, it will have a compile-time error
}
2. compile-time safe
list.add("default)
if (list.get(7)) { // this won't compile-time error
}
3. compile-time safe
val index = 7
if (0 <= index && index < list.size) {
if (list.get(index)) { // this won't compile-time error
}
}
the reason I wanna create @SafeGetter
(a placeholder annotation name) is to prevent engineer forgot to handle IndexOutOfBoundsExceptions or NPE
to reduce runtime error (in our apps)
does the above implementation possible? and if yes, is there any reference/tutorial I can read? or maybe slack channel discussion? (if #general is not the right place to ask this kind of topic)user
05/07/2020, 3:30 PMSandy
05/07/2020, 9:54 PMDes
05/08/2020, 11:29 AMMadalin Valceleanu
05/08/2020, 2:27 PMDes
05/08/2020, 3:01 PMJohnDoe
05/08/2020, 3:11 PMShawn
05/08/2020, 3:15 PMShawn
05/08/2020, 3:16 PMShawn
05/08/2020, 3:17 PM