Paulius O
10/30/2021, 6:50 AMval myVal = (
a.size +
b.size +
c.size)
Is there a way to change klint settings to align it automatically? I would prefer all to be offset at the same level.
If there isn’t maybe someone can explain why indentation the way that it’s working now is better?andylamax
10/31/2021, 7:40 AMobject Test {
@get:Composable
val primary: Color get() = TODO()
}
and
object Test {
val primary: Color
@Composeable
get() = TODO()
}
Compose seem to be happy with the later and not with former. I though these where same. Anyone?Seb C
10/31/2021, 2:35 PMMichael de Kaste
11/01/2021, 11:24 AMAlexander Suraphel
11/01/2021, 2:12 PMR
supposed to be set by default on this snippet?althaf
11/01/2021, 2:23 PMvar button = document.querySelector('.button');
var label = document.querySelector('h4');
var clickStream = Rx.Observable.fromEvent(button, 'click');
var doubleClickStream = clickStream
.bufferWhen(() => clickStream.debounceTime(250))
.map(arr => arr.length)
.filter(len => len === 2);
doubleClickStream.subscribe(event => {
label.textContent = 'double click';
});
doubleClickStream
.delay(1000)
.subscribe(suggestion => {
label.textContent = '-';
});
Stefan Oltmann
11/01/2021, 3:13 PMplugins {
kotlin("multiplatform")
}
kotlin {
mingwX64("native") {
binaries {
executable()
}
}
}
tasks.withType<Wrapper> {
gradleVersion = "7.2"
distributionType = Wrapper.DistributionType.BIN
}
PriNova
11/02/2021, 11:23 AMfun main() {
val value: Int = 2
showValue<Int>(value)
}
inline fun <reified T> showValue(value: T) = println("$value")
The decompiled Java shows that the primitive int will be boxed into an Integer.
And the function-signature has an Object as parameter-type.
I think, although the reified function will be inlined, that the use of primitives, or whatever object for T, stays the same, because of inlining.
Is this possible?
Thank youMarko Kunic
11/03/2021, 4:41 PMTim Abil
11/03/2021, 5:35 PMis
operator and class comparison?
sealed class MyClass {
object ONE : MyClass()
object TWO : MyClass()
}
inline fun <reified T> List<MyClass>.findClass(): T? {
return find { it is T } as T
}
fun <T: Any> List<MyClass>.findClass(clazz: KClass<T>): T? {
return find { it::class == clazz } as T?
}
Justin Tullgren
11/03/2021, 7:10 PMDeprecated
annotation ReplaceWith
when the argument is a receiver function type?
@Deprecated
fun factory(initializer: Builder.() -> Unit): Type = Builder().apply(initializer).build()
Marko Novakovic
11/04/2021, 9:58 AMChristopher Stocks
11/04/2021, 3:29 PMJilles Soeters
11/04/2021, 3:51 PMursus
11/04/2021, 7:21 PMclass BusinessMessageIdColumnAdapter : ColumnAdapter<BusinessMessageId, String> {
override fun decode(databaseValue: String): BusinessMessageId = BusinessMessageId(databaseValue)
override fun encode(value: BusinessMessageId): String = value.value
}
for every type of id, which is annoying
I know I could get it via reflection, but .. probably looking for a "hack" like this (the enumValues function)
@Suppress("FunctionName") // Emulating a constructor.
inline fun <reified T : Enum<T>> EnumColumnAdapter(): EnumColumnAdapter<T> {
return EnumColumnAdapter(enumValues())
}
KV
11/05/2021, 8:06 PMelect
11/05/2021, 9:20 PM@FunctionalInterface
in the first case and fun interface
in the second case here? What's the different between the annotation and fun interface
?Lokik Soni
11/06/2021, 12:58 PMdata class BatteryProfile(
private val _temperature: Int,
) {
val temperature get() = logic to convert _temperature from kelvin to celsius
}
So i applied the above solution but i am feeling it is not good way also I have not seen data class primary constructor field as privete in any example.
Please tell me if it is correct way or if wrong so how to achieve this.Ansh Tyagi
11/07/2021, 7:42 AM.
├── build.gradle.kts
├── src
├── settings.gradle.kts
└── JavaProj(ant)
├── ant.settings
└── build.xml
i hope i could make this file stucture clear. but the issue is i could not import the java proj in the kotlin. I think its something realted to including the proj in settings.gradle.kts but searching stackoverflow wasnt enough. Is there something else i ned to do as well while importing another subproj?Alexander Suraphel
11/07/2021, 2:41 PMString
and Char
?Alexander Suraphel
11/07/2021, 2:46 PM*fun* <T : Comparable<T>>
and *fun* <Comparable<T>>
?Martin Barth
11/08/2021, 10:23 AM"-" -> if (aggregate is Minus) Minus(*aggregate.expressions, nextExpression) else Minus(aggregate, nextExpression)
"+" -> if (aggregate is Plus) Plus(*aggregate.expressions, nextExpression) else Plus(aggregate, nextExpression)
....
I wanted to make that easier, but i am failing. My Idea was something like this:
private inline fun <reified T> myIdea(aggregate: InfixExpression, nextExpression: Expression): T = if (aggregate is T)
T(*aggregate.expressions, nextExpression)
else
T(aggregate, nextExpression)
using the Type T as a Constructor does not work. Any advice?David Lax
11/09/2021, 3:47 AMsmit01
11/09/2021, 6:52 AMArpit Shukla
11/09/2021, 10:23 AMprivate val _data = MutableStateFlow(0)
1. val data: StateFlow<Int> = _data
2. val data = _data.asStateFlow()
In other words, what does asStateFlow()
do?Robert Jaros
11/09/2021, 12:46 PMjeggy
11/09/2021, 1:23 PMNikolay Lebedev
11/09/2021, 1:41 PM{"name": "Foo"}
and {"age": 42}
and want to get {"name": "Foo", "age": 42}
object.dave08
11/09/2021, 2:32 PMdata
and inner
modifiers to class
compatible together?Michael Clancy
11/09/2021, 3:18 PMsomeFlow.transform {
if (someCondition) {
emit(Resource.Loading(someIntermediateResult))
} else {
emit(Resource.Error("Couldn't compute")
//Want to place something here to skip code below and move to next item in flow
}
emit(Resource.Success(finalResult)
Any ideas? Feel like I am missing something simple
Thanks, MichaelMichael Clancy
11/09/2021, 3:18 PMsomeFlow.transform {
if (someCondition) {
emit(Resource.Loading(someIntermediateResult))
} else {
emit(Resource.Error("Couldn't compute")
//Want to place something here to skip code below and move to next item in flow
}
emit(Resource.Success(finalResult)
Any ideas? Feel like I am missing something simple
Thanks, Michaelephemient
11/09/2021, 7:51 PMreturn@transform
will exit the lambda expression earlyMichael Clancy
11/10/2021, 9:30 AM