karelpeeters
02/23/2019, 8:22 AModay
02/23/2019, 6:42 PMSlava Glushenkov
02/24/2019, 7:12 AMPaul N
02/24/2019, 5:09 PMColour(val red:Double, val green: Double, val Blue: Double)
what's the best way of defining some pre-defined colours, e.g. White being Colour(1.0,1.0,1.0)
?karelpeeters
02/24/2019, 5:11 PMclass Colour(...) {
companion object {
val White = Colour (1.0, 1.0, 1.0)
....
}
}
Used like Colour.White
.Neron.L
02/27/2019, 9:34 AMhalirutan
02/27/2019, 9:46 AM<name>Carla</name>
to finally get "<name>Carla</name> and <name>Bob</name> went to school".
Is there an easy way in Kotlin to achieve this without tracking the lengths that I have already inserted?Frido
02/27/2019, 10:43 AM/**
* @property name ...
*/
class Person(private val name: String)
KDoc doesn't generate this. Only if I change property to param. Reading the linked SO thread it appears to actually be a property though. Can someone clarify please?
https://stackoverflow.com/questions/45032436/what-is-the-difference-between-properties-and-parameters-in-kotlinptheocharis
02/27/2019, 5:49 PMdata class GreetingDto(
val greeting: String,
val name: String
)
then I get another error:
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: app.greeting.GreetingDto(LinkedHashMap)
Mark
02/28/2019, 8:35 AMvar background: Drawable
and I want to create a Kotlin class implementing this interface and extending a java class that already defines setBackground(Drawable)
and Drawable getBackground()
. In Java, I don't need to do anything because the new subclass automatically implements these interface methods. In Kotlin, I get a compile error that the new subclass does not implement those interface methods. How to achieve this?Kenneth
02/28/2019, 12:33 PMUraniam9
02/28/2019, 3:52 PMJoe Bradshaw
02/28/2019, 7:50 PModay
03/01/2019, 9:25 AMthanksforallthefish
03/01/2019, 9:34 AM1.3.21
and the base classes are from spring (maybe I can post in spring channel as well, but this seems more generally related to kotlin, spring is relevant only because I have no influence on how enhance
is called, it has to accept `null`s)zucen.co
03/01/2019, 10:14 AMval pair = Pair(1,"xxx")
map.put(*pair)
KÖB
03/01/2019, 9:05 PMscottiedog45
03/02/2019, 5:40 PMOlav Hermansen
03/03/2019, 8:14 AMitems.stream().filter { it.someStuff.equals(search) }.findFirst().orElseThrow( *insert exception* )
I tried to put UnsupportedOperationException() but get problem with ExceptionSupplier. How should I do this?Mark McPartland
03/03/2019, 11:44 AModay
03/03/2019, 8:32 PMRuckus
03/03/2019, 9:57 PMpublic inline fun <K, V> MutableMap<K, V>.getOrPut(key: K, defaultValue: () -> V): V {
val value = get(key)
return if (value == null) {
val answer = defaultValue()
put(key, answer)
answer
} else {
value
}
}
but it seems to me (based on the kdoc) that is should be more like
public inline fun <K, V> MutableMap<K, V>.getOrPut(key: K, defaultValue: () -> V): V {
return if (contains(key)) {
getValue(key)
} else {
val answer = defaultValue()
put(key, answer)
answer
}
}
oday
03/04/2019, 3:55 PMname
field, then reconstruct this sortedmap agianbjonnh
03/04/2019, 6:54 PMScott White
03/04/2019, 9:32 PMdavec
03/05/2019, 12:56 AM("a".."z").map{ it }
doesn't work (compiler error), can't map a String range.voddan
03/05/2019, 11:47 AMlist.size == list.distinct().size
, which is efficient, but uglyIaroslav Postovalov
03/05/2019, 4:37 PMkotlin.jvm.JvmSynthetic
?Richard Cumberland
03/05/2019, 5:01 PMMatthew Hall
03/05/2019, 5:39 PMMatthew Hall
03/05/2019, 5:39 PMkarelpeeters
03/05/2019, 5:44 PMList
implements Iteratable
and they're both mapped to the respective Java type.fred.deschenes
03/05/2019, 6:02 PMMatthew Hall
03/05/2019, 9:46 PMkarelpeeters
03/05/2019, 10:22 PMaraqnid
03/06/2019, 10:26 AMkarelpeeters
03/06/2019, 11:10 AMMatthew Hall
03/08/2019, 5:48 PMEnum
, we get the erased type--which for an out MyEnum
type variable just gives MyEnum.class
.? extends Foo
to just Foo
for our use case