mkporwit
07/14/2017, 12:13 AMString!
but got Array<String>
insteadhaxpor
07/14/2017, 1:54 AMfilter{}
, map{}
over normal loop code. Yes, I like to use those. But peek into the code from IDE reveals that actually filter{}
is not better than normal loop as it dynamically creates a new ArrayList
object to hold filtered elements. So normal loop would slightly has better performance.
My question is as IDE suggests me like this
- Is the performance that significant (although I can’t feel any difference)?
- Is there anyone already did performance test comparing between filter{}
, map{}
etc against normal way?
- Should I always use lambda functions as also suggested by IDE? (I want to but from above, I didn’t feel safe)rednifre
07/14/2017, 4:21 PMilyagulya
07/14/2017, 4:29 PM(Int) -> Unit
and provide them from Java to Kotlin.
However, in Java i need to provide Function1<Int, Unit>
instead of Consumer<Int>
or something like this.
Due to this limitation i need to return Unit.INSTANCE
or use custom interfaces instead of closures
How can i avoid this problem?ziggy42
07/14/2017, 5:16 PMgregd
07/14/2017, 5:25 PM!!
calls altogether?kevinmost
07/14/2017, 6:55 PMval str : String? = ""
str{THIS_IS_NOT_SAFE_PLS_PAY_ATTENTION}.length
😉dumptruckman
07/14/2017, 11:32 PMsupaham
07/16/2017, 6:39 PMWeakReference<Entity?>
more proper than WeakReference<Entity>
.
If I had to guess, I'd say it will always NPE after GCdiesieben07
07/16/2017, 6:59 PMDelegates.vetoable
?simkis
07/17/2017, 12:42 PMpublic interface Listener{
void success(Model model);
void error();
}
to make it useable from kotlin without annonymous inner class? Do I need to declare interface with only one method? Or there is some other workaround?
I want to use it like this
modelManager.identifyModelWithCameraUrl(cameraUrl) { cameraModel ->
}
mfiano
07/18/2017, 8:13 AMdiesieben07
07/18/2017, 9:46 AM[MyClass]
.jw
07/18/2017, 2:29 PMorangy
07/18/2017, 4:58 PMorangy
07/18/2017, 5:41 PMmfiano
07/18/2017, 7:30 PMnapperley
07/19/2017, 6:40 AMmfiano
07/19/2017, 7:16 AMlorinc
07/19/2017, 1:07 PMjackmiras
07/19/2017, 3:33 PMorangy
07/19/2017, 9:37 PMalenkart
07/19/2017, 10:33 PMghosalmartin
07/20/2017, 9:32 AMgalex
07/20/2017, 12:39 PMnyxcode
07/20/2017, 6:07 PMinterface SerializationAdapter<T : Any> {
fun serialize(obj: T, output: ByteBuf)
fun deserialize(input: ByteBuf): T
}
data class PacketDeclaration<T : Packet>(val id: Int,
val clazz: KClass<T>,
val serializer: SerializationAdapter<T>)
interface PacketRegistry {
fun <P : Packet> resolve(clazz: KClass<P>): PacketDeclaration<P>
}
fun serialize(byteBuf: ByteBuf, packet: Packet) {
val registry = ...
val dec = registry.resolve(packet::class)
dec.serializer.serialize(packet, byteBuf)
// ^^ Out-projected type 'SerializationAdapter<out Packet>' prohibits the use of 'public abstract fun serialize(obj: T, output: ByteBuf): Unit defined in de.nyxcode.dmn.protocol.SerializationAdapter
}
Any recommendations?Paul Woitaschek
07/21/2017, 8:20 AMraulraja
07/21/2017, 11:17 AMcollect
to map
and filter
in one pass.Paul Woitaschek
07/21/2017, 12:18 PMgregd
07/21/2017, 1:24 PMgregd
07/21/2017, 1:24 PMvoddan
07/21/2017, 1:26 PMfoo()
and a value foo
in one scope (separate name spaces for functions and properties)gregd
07/21/2017, 1:33 PMelizarov
07/21/2017, 1:43 PMval foo = this::foo
in Kotlin and have hassle-free for both foo(...)
invocations and passing foo
around as a value. I’m not sure if that helps in your case, though.gregd
07/21/2017, 1:51 PMelizarov
07/21/2017, 2:28 PMautoclosure
is helping to make Kotlin code easier to read and understand for the less experienced crowd.gregd
07/21/2017, 3:43 PMKT-15667
will make it into :kotlin: 1.2