Tim Malseed
01/17/2020, 1:08 AMNAME_SHADOWING
warning in Kotlin, globally? If not, where would I file a request for this feature?rcd27
01/17/2020, 8:15 AMKotlin
programmer: you are pretty able to write Scala
as well 🙂 Decided to shift to FP, and realized that JetBrains
prepared me for that stuff somehow ❤️Joost de Vries
01/17/2020, 9:41 AMJérôme Gully
01/17/2020, 10:29 AMiex
01/17/2020, 10:37 AMResult<T>
but which 1) Can return an arbitrary type as error and 2) Doesn't have a success payload. Here's the solution I came up with. I wonder if it can be expressed more elegantly?
sealed class EmptyResult<E> {
class Success<E> : EmptyResult<E>()
data class Failure<E>(val error: E): EmptyResult<E>()
}
fun foo(): EmptyResult<String> = EmptyResult.Success()
armaxis
01/17/2020, 3:33 PMval nullableList: List<String>? = listOf()
val nonNullableList: List<String> = nullableList as List<String>
iex
01/17/2020, 4:22 PMec
01/17/2020, 8:25 PMantonkeks
01/18/2020, 11:45 AMfun <T: Any> register(c: KClass<T>, i: T) {}
fun main() {
listOf(ArrayList::class, LinkedList::class).forEach { // any different classes here
register(it, it.createInstance())
}
}
Michał Kalinowski
01/18/2020, 12:22 PMShan
01/19/2020, 7:52 AMghedeon
01/19/2020, 12:51 PMinterface I
class Main : Base<MainParam<*>>
class MainParam<T : I> : BaseParam
interface Base<T : BaseParam>
interface BaseParam
B. Doesn't (Type argument is not within its bounds
)
interface I
class Main : Base<Main.MainParam<*>> {
class MainParam<T : I> : BaseParam
}
interface Base<T : BaseParam>
interface BaseParam
ec
01/19/2020, 4:05 PMMatthieu Stombellini
01/19/2020, 4:32 PMval lexer = // an instance of LixyLexer, line 180
val exc = assertFailsWith<LixyException> {
lexer.tokenize("....")
}
assertNotNull(exc.message)
assert(exc.message!!.contains("token ends"))
causes this exception:
java.lang.VerifyError: JVMVRFY027 récepteur incompatible avec la classe déclarante; classe=guru/zoroark/lixy/LixyTest$Lixy incoherent matcher results cause exception (end is too far)$lexer$1, méthode=invoke(Lguru/zoroark/lixy/LixyDslEnvironment;)V, pc=26
Exception Details:
Location:
guru/zoroark/lixy/LixyTest$Lixy incoherent matcher results cause exception (end is too far)$lexer$1.invoke(Lguru/zoroark/lixy/LixyDslEnvironment;)V @26: JBinvokevirtual
Reason:
Type 'guru/zoroark/lixy/LixyTest$Lixy incoherent matcher results cause exception (end is too far)$lexer$1$1' (current frame, stack[1]) is not assignable to 'guru/zoroark/lixy/LixyDslEnvironment'
Current Frame:
bci: @26
flags: { }
locals: { 'guru/zoroark/lixy/LixyTest$Lixy incoherent matcher results cause exception (end is too far)$lexer$1', 'guru/zoroark/lixy/LixyDslEnvironment', '[Z' }
stack: { 'guru/zoroark/lixy/LixyDslEnvironment', 'guru/zoroark/lixy/LixyTest$Lixy incoherent matcher results cause exception (end is too far)$lexer$1$1' }
at guru.zoroark.lixy.LixyTest.Lixy incoherent matcher results cause exception (end is too far)(LixyTest.kt:180)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
(...snip...)
However, I am unable to replicate this on my CI environment, everything works fine there... Any ideas?Luke Sleeman
01/20/2020, 7:04 AMval myList = listOf {
add("Blah")
add("Foo")
if(somethingIsTrue) {
add("More")
add("Stuff")
}
}
I seem to remember somebody talking about it, or tweeting about it? Possibly it was coming to the standard libraries?bum
01/20/2020, 11:36 AMtop level variable
and local variable
?
val outer = 1
fun main() {
val inner = 2
println(::outer.name) // outer
println(::inner.name) // [References to variables aren't supported yet]
}
I'm confused why println(::inner.name)
throws error 😕Sagar Suri
01/20/2020, 12:21 PMSubClass
but a factory which will give the instances of these SubClasses
and also provide access to the common functions which are in the parent class. Is it possible?
class GodClass {
fun common(){}
fun a(){}
fun b(){}
fun c(){}
fun d(){}
}
abstract class ParentClass {
fun common(){}
}
class SubClass1: ParentClass {
fun a(){}
}
class SubClass2: ParentClass {
fun b(){}
fun c(){}
}
Kroppeb
01/20/2020, 12:24 PMsteenooo
01/20/2020, 1:12 PMrrva
01/20/2020, 3:06 PMWesley Acheson
01/20/2020, 4:20 PMval configuration = if (config != null) config else
{
val retrieved = configRepo.findByMerchantId(id)
if (retrieved != null) retrieved else MerchantBillConfig(id, emptyList(), CurrencyIso("XXX"), false)
}
I mean if a value is passed use that else try to retrieve one else generate a default one.kyleg
01/20/2020, 11:38 PMkotlinx.coroutines.async(context, start, block)
appears to be deprecated. What am I supposed to replace it with? I want to put async(start=LAZY) { someSuspend() }
in my code, but I also don’t want to use deprecated functions.
Technically I’m updating some third-party library’s documentation, and I’d rather my PR not use deprecated methods. The current sample code uses async {…}
and I’d rather not dramatically alter the sample code, but hew closely to the original.Gyuhyeon
01/21/2020, 2:28 AMVitali Plagov
01/21/2020, 9:09 AMLastExceed
01/21/2020, 11:17 AMLong
) and i figured it might be worth using a typealias or inline class to clarify that using this number for e.g. multiplication makes no sense.
if possible, I am looking for a generalized answer so I know how to make this decision myself in the futureGurupad Mamadapur [FH]
01/21/2020, 11:40 AMVitali Plagov
01/21/2020, 11:47 AMifEmpty{}
, but it returns the entire collection if it is not empty, while I don’t need the collection and just it’s first element.LastExceed
01/21/2020, 12:09 PMPacket
(for networking) that needs a serialize
and deserialize
function. the former is easy, just a regular abstract function with a ByteWriteChannel
param to write the packet into. the latter however needs to be either a top-level extension function for ByteReadChannel
or in the companion object, neither of which allows the abstract
keyword (obviously). how do I ensure that each Packet
class implements a deserialize
factory function ?Jérôme Gully
01/21/2020, 12:46 PMsbyrne
01/21/2020, 1:45 PMSystem.out.print("\033[100D")
. Kotlin does not like \033
, how do I do that?