Brian Dilley
12/08/2020, 4:28 AMNir
12/08/2020, 3:58 PMrun
or with
work with an enum class? basically a way to introduce a scope where we can reference the enumerators without qualificationdiesieben07
12/08/2020, 4:17 PMinterface Base<T>
and Concrete<T : Any> : Base<T>
. In a method which accepts Base<T>
I now need to check is Concrete<T>
, but that's impossible because in the method T
is not constrained to Any
(but it has to be, if I have a Concrete<T>
...
See thread for more code.xetra11
12/08/2020, 10:54 PMFile.walk
however I am not able to get it resolved. IntelliJ always shows me java.nio.file.Files.walk
instead of the extension
public fun File.walk(direction: FileWalkDirection = FileWalkDirection.TOP_DOWN): FileTreeWalk =
FileTreeWalk(this, direction)
Nish Patel
12/09/2020, 1:08 AMMartin Barth
12/09/2020, 7:08 AMprivate fun <Long> List<Long>.combinationSums(): Sequence<Long> {
val list = this
return sequence {
for (i in 0 until list.count()) {
for (j in i + 1 until list.count()) {
val sum: Long = list[j] + list[i]
yield(sum)
}
}
}.distinct()
}
I am getting a compiler error for the `list[i] + list[j]:
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public inline operator fun BigDecimal.plus(other: BigDecimal): BigDecimal defined in kotlin
public inline operator fun BigInteger.plus(other: BigInteger): BigInteger defined in kotlin
public operator fun <T> Array<TypeVariable(T)>.plus(element: TypeVariable(T)): Array<TypeVariable(T)> defined in kotlin.collections
christophsturm
12/09/2020, 10:40 AMopen class ApplicationException(message: String, cause: Throwable?) : RuntimeException(message, cause)
rtsketo
12/09/2020, 10:53 AMImageView.photo(url: String) = { .. }
photo(url: String) = { .. }
Is there a way to call the second one in the scope of an ImageView like below?
ImageView(context).apply {
...
photo(url)
...
}
Jason
12/09/2020, 12:13 PMSarah Gross
12/09/2020, 3:23 PM_whenever_(myMethod(
_any_(), _any_(),_any_(), _any_(), _any_(), _any_(), _any_(), _any_())
).thenReturn
hho
12/09/2020, 5:30 PMbod
12/09/2020, 7:09 PMString.map
fun that returns a String (instead of the generic one returning a List<R>) somewhere?holgerbrandl
12/09/2020, 8:28 PMAndré Benda
12/09/2020, 9:22 PMwasyl
12/09/2020, 10:08 PMfoo(.Baz)
instead of foo(Foo.Bar.Baz)
. It hope it’s considered for implementation in the relatively near future, would help greatly with verbosity!allan.conda
12/10/2020, 8:24 AMstateDelegate
aside from the constructing the backing field and the public read-only state
// util
inline operator fun <T> StateFlow<T>.getValue(thisObj: Any?, property: KProperty<*>): T = value
inline operator fun <T> MutableStateFlow<T>.setValue(thisObj: Any?, property: KProperty<*>, value: T) {
this.value = value
}
// usage
private val stateDelegate: MutableStateFlow = MutableStateFlow(...)
private var _state: State = stateDelegate
val state: StateFlow<State> = stateDelegate
fun foo() {
_state = State(...)
}
Benjamin Vallet
12/10/2020, 9:32 AMNikky
12/10/2020, 10:15 AMsbeve
12/10/2020, 12:16 PMGarouDan
12/10/2020, 3:38 PMrocketraman
12/10/2020, 4:14 PM<http://java.io|java.io>.Serializable
class. However accessing foo
from @delegate:Transient val foo: Foo by lazy { }
causes a NPE on deserialization. How can I create a lazy property that the VM does not try to serialize, but at the same time does the right thing?Scott Whitman
12/10/2020, 7:18 PMsealed class Fruit {
class Apple(val color: String) : Fruit()
object Orange : Fruit()
}
fun main() {
val list = listOf(Fruit.Apple("red"), Fruit.Orange)
for (item in list) {
if (/* item is object? */) /* do something */
else /* do something else */
}
}
Alfred Lopez
12/10/2020, 7:51 PMearroyoron
12/10/2020, 9:42 PMval result = run { ... }
result is not actually calculated there, but when is needed (lazy), isn't it?
I know this is the usual behaviour when using a functional style but I couldn't find any reference to give a clear explanation to my colleague.sbeve
12/10/2020, 10:31 PMandylamax
12/11/2020, 1:33 AMjvm
. I am using a bunch of Deffered<*>
for async calls, how do I extract and await the values of Defered<*>
from Java code?Andy Gibel
12/11/2020, 3:09 AMobject MoonWidgetInput
object MoonWidgetOutput
object MoonWidgetData
abstract class BaseVehicle<INPUT, OUTPUT>
abstract class BaseWidget<INPUT, DATA, OUTPUT>() {
abstract var vehicle : BaseVehicle<INPUT, OUTPUT>
}
class MoonRover : BaseVehicle<MoonWidgetInput, MoonWidgetOutput>()
class MoonWidget :
BaseWidget<MoonWidgetInput, MoonWidgetData, MoonWidgetOutput>(){
override var vehicle = MoonRover()
}
Martin Barth
12/11/2020, 7:17 AMelect
12/11/2020, 8:27 AMvar cb = new Function1<? extends InputTextCallbackData, Boolean> (() -> true);
then the extends
complains
Wildcard type '? extends imgui.classes.InputTextCallbackData' cannot be instantiated directly
Daniele Segato
12/11/2020, 11:10 AMcallbackFlow
does that mean that it may become binary incompatible in the future?
Thanks.