Ruckus
05/08/2018, 4:10 PMarr.associate { it to f(it) }
Michael
05/08/2018, 6:40 PMRussell Davis
05/08/2018, 11:28 PMAregev2
05/09/2018, 5:38 AMarekolek
05/09/2018, 8:11 AMinline fun <reified K, reified V> Any?.asLinkedMap(): LinkedHashMap<K, V>? {
return (this as? Map<*, *>)
?.takeIf {
it.entries.all { (key, value) -> key is K && value is V }
}
?.map { (key, value) -> Pair(key as K, value as V) }
?.toMap(LinkedHashMap())
}
Ruckus
05/09/2018, 3:22 PMTuplesN
classes have package private constructors, with the Tuples
class providing static methods for creating them.)Ruckus
05/09/2018, 3:33 PMMarc Steven
05/10/2018, 8:14 AMAndrei
05/10/2018, 9:36 AMsudhanshu singh
05/10/2018, 10:36 AMUtils.Kt
object Utils {
fun doSomething(){
}
vs
Utils.Kt
fun doSomething(){
}
dagguh
05/10/2018, 1:55 PMNote, however, that members overridden in this way do not get called from the members of the delegate object, which can only access its own implementations of the interface membersThis behavior is the opposite of what a manual delegation pattern does. What’s the rationale behind this difference?
wineluis
05/10/2018, 1:58 PMtylerwilson
05/10/2018, 2:25 PMdata class Item<T>(val operand1: T, val operand2: T) {
val result: T = operand1 / operand2
}
But it gives me errors about BigDecimal (I guess this is the first class it tried to match. So I need to constrain T to be only types that support division, like T: Number, T: divideBy or something. Is this possible in Kotlin? Thank you!droidrcc
05/10/2018, 2:39 PMSackCastellon
05/10/2018, 10:41 PMjava.time.LocalDateTime
to org.joda.time.DateTime
and back, so far I have created this extensions which seem to work fine:
fun java.time.LocalDateTime.toJoda(): org.joda.time.DateTime = DateTime(this.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli())
fun org.joda.time.DateTime.toJava(): java.time.LocalDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(this.millis), ZoneId.systemDefault())
The LocalDateTime is used by JavaFX's DatePicker, and the DateTime is used by Exposed.
Any comments or suggestions?sngrekov
05/11/2018, 7:20 AMrobstoll
05/11/2018, 1:02 PMfun foo(s: String?){}
is there a way to force that one has to pass String?
and cannot pass String
?ylemoigne
05/11/2018, 1:42 PMWorkflow kotlin-pull-requests reports error: TypeError: Cannot call method "indexOf" of null (kotlin-pull-requests/on-pull-request-link-add-tag-make-major#17)
Contact project admin Andrey Breslav
on post.Ruckus
05/11/2018, 8:10 PMpackage demo
val name = "package"
fun main(args: Array<String>) {
val name = "local"
class Test {
val name = "class"
val a get() = name // returns "local"
val b get() = this.name // returns "class"
val c get() = demo.name // returns "package"
}
}
Ruckus
05/11/2018, 8:53 PMany
and all
defined on Array<out T>
instead of Array<T>
?Danny
05/11/2018, 8:59 PMkotlin-reflect
on Windows? We were running into an issue where windows 10 defender is marking kotlin-reflect-1.2.41
as a virus of type Trojan:Win32/Vigorf.A
osamarao
05/11/2018, 10:47 PMfrellan
05/12/2018, 1:45 PMfun findAll(modelClass: KClass<out BaseModel>): List<modelClass> {
return Ebean.find(modelClass::class.java).findList()
}
But that obviously is not the right syntaxPere Casafont
05/12/2018, 7:00 PMkenkyee
05/13/2018, 7:02 PMarekolek
05/13/2018, 7:23 PMwhen
expression is exhaustive?
fun test(x: Int): Int {
assert(x in 1..3) // doesn't help
if (x !in 1..3) throw IllegalArgumentException() // doesn't help
return when (x) {
1 -> -1
2 -> 0
3 -> 1
}
}
muralimohan962
05/14/2018, 9:24 AMjackjill
05/14/2018, 1:26 PMktor
users here ??juliocbcotta
05/14/2018, 2:57 PMabstract class TestCase<T : Activity>() {
val classz = (javaClass
.genericSuperclass as ParameterizedType).getActualTypeArguments()[0] as Class<T>
@Rule
@JvmField
val rule = IntentsTestRule(classz, false, false)
}
This seems to work to open FooTestCase: TestCase<ActivityA>
, but not to BarTestCase: FooTestCase
...Andrei
05/14/2018, 3:20 PMconst val
?Andrei
05/14/2018, 3:20 PMconst val
?Andreas Sinz
05/14/2018, 3:21 PMconst val foo = """ some text """.trimMargin()
?Shawn
05/14/2018, 3:21 PMconst
it needs to be a string or a primitive that the kotlin compiler can inline where the val
is usedAndreas Sinz
05/14/2018, 3:22 PMAndrei
05/14/2018, 3:22 PMkarelpeeters
05/14/2018, 3:24 PMShawn
05/14/2018, 3:24 PMconst
Andrei
05/14/2018, 3:24 PMShawn
05/14/2018, 3:24 PM