tianhao
07/25/2018, 6:02 AMaccessing non-final property in constructor
not sure how is the fix for that? Thanks
class KafkaService {
val producer: KafkaProducer<String, String>
init {
val props = Properties()
props[ProducerConfig.BOOTSTRAP_SERVERS_CONFIG] = "127.0.0.1:9092"
props[ProducerConfig.CLIENT_ID_CONFIG] = "DemoProducer"
props[ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG] = StringSerializer::class.java.name
props[ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG] = StringSerializer::class.java.name
producer = KafkaProducer(props)
}
fun sendToKafka(topic: String, message: String) {
val producerRecord: ProducerRecord<String?, String> = ProducerRecord(topic, null, message)
producer.send(producerRecord)
}
}
Shahnish
07/25/2018, 7:28 AMelect
07/25/2018, 9:24 AMval <K, V>SortedMap<K, V>.first get() =...
christophsturm
07/25/2018, 10:19 AMgetId()
method, why can’t i use override val id
?arekolek
07/25/2018, 1:16 PMJsonRpcResponse<R>
with some concrete R
type and pass that class, then it would work(?)elect
07/25/2018, 3:28 PMClassLoader.getSystemResourceAsStream(filename)
, but now it returns null
. Paths.get(".")
shows it's the right location. What can be wrong? (ps: function is top level)nwh
07/25/2018, 3:54 PMDefaultErrorMessages.java
but didn't see anything thererocketraman
07/25/2018, 7:28 PMinline fun <reified T: Any?> foo()
, where at my call-site T
is a List<Something>
, is there a way to determine Something
inside the inline fun?stegod10
07/26/2018, 8:27 AMahegazy
07/26/2018, 9:37 AMinternal
if my code is not separated into modules?mp
07/26/2018, 10:33 AMfun Boolean.throwIfTrue(exception: Exception) { if (this) throw exception }
fun Boolean.throwIfFalse(exception: Exception) { if (!this) throw exception }
Don't think that I`m first how think about it 😃 and better use out-of-the-box approachvpriscan
07/26/2018, 1:34 PMdknapp
07/26/2018, 2:14 PMfor (i in 0 until someValue)
? repeat(someValue)
?miha-x64
07/26/2018, 7:34 PMIdeally, we'd like to support functions of arbitrary arity in Kotlin. In practice, a JVM method cannot have more that 255 parameters, so this is the limit for us as well.But... vararg... from JVM's point of view is a single argument....
josephivie
07/26/2018, 7:38 PMinline class
a lot. This is awesome. There are many things that make more sense as an independent class (angles especially), but it seems like a waste of performance to make them that way. No more! With it just as performant, I'm totally using this.karelpeeters
07/26/2018, 7:47 PMjw
07/26/2018, 7:53 PMgsala
07/26/2018, 9:19 PMredrield
07/27/2018, 1:05 AMinline class
be used to make a union typeKrs
07/27/2018, 6:29 AMelect
07/27/2018, 8:09 AMName?
gets mapped to String
instead String?
..?
inline class Name(val s: String)
fun foo(n: Name?) { ... } // `Name?` here is mapped to String
yawkat
07/27/2018, 9:29 AM@Deprecated(message = "java only", level = DeprecationLevel.HIDDEN)
to make functions java-only?Slackbot
07/27/2018, 11:02 AMAregev2
07/27/2018, 1:14 PMGrigori
07/27/2018, 3:11 PMrocketraman
07/27/2018, 9:54 PM@Suppress
annotation results in a ClassCastException
, and without it runs without an error:
fun main(args: Array<String>) {
fun <T> foo(block: () -> T): T = block()
@Suppress("ConstantConditionIf")
if (true) foo { "foo" }
}
tipsy
07/28/2018, 1:29 AMfor (entry in map) {
if (myValue.startsWith(entry.key)) {
myAction()
return true
}
}
return false
paulex
07/28/2018, 2:53 PMgildor
07/28/2018, 3:34 PMAregev2
07/28/2018, 7:50 PM