aerb
12/29/2017, 10:41 PMredrield
12/30/2017, 7:06 AMBehaviorSubject<Int?>
, but IntelliJ is insisting that I have to pass an Int to onNextgroostav
12/31/2017, 6:51 AMt
of something thats declared as object Thingy
, that is not equal to Thingy.INSTANCE
. I could update all my when statements to use when(it) { is Thingy ->
rather than when(it) { Thingy ->
, but that seems cryptic.groostav
12/31/2017, 6:52 AMreadResolve
method on all things declared as object
.looki
12/31/2017, 10:43 AMandredasilvapinto
12/31/2017, 7:01 PMjava.lang.VerifyError: Bad type on operand stack
(full error on the gist comment). Why is that?dave08
01/01/2018, 2:00 PM"0101-1002-0909-0210-1115-1511".split("-")
.flatMap { it.chunked(2).map { it.toInt() } }
.map { if (it > 9) (it + 55).toChar() else (it + 48).toChar() }
.chunked(2)
I need: 11:A2:99:2A:BF:FB
, how could I do that idiomatically, also, is there a simpler algo for this? It's converting to hex..birgersp
01/01/2018, 2:33 PMViral
01/02/2018, 5:17 AMrobstoll
01/02/2018, 12:08 PMclass A<T>(val a: B<T>.()->Unit)
I tried:
class A<T1, T2: (B<T>.()->Unit)? >(val a: T2)
But that failes stating that an extension function type cannot be used as upper bound. I want to be able to have the parameter nullable in some places and not nullable in others without creating two classes for itclaudiug
01/02/2018, 12:47 PMpoohbar
01/02/2018, 4:40 PMjava.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
...
nicola.de.fiorenze
01/02/2018, 5:03 PMinterface Base {
fun print()
fun getValue() : String
}
class BaseImpl : Base {
override fun print() { print(getValue()) }
override fun getValue(): String {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
class Derived(private val b: Base) : Base by b {
override fun getValue(): String = "hello"
}
fun main(args: Array<String>) {
val b = BaseImpl()
Derived(b).print() // prints 10
}
obviously the output is
Exception in thread "main" kotlin.NotImplementedError: An operation is not implemented: not implemented
at BaseImpl.getValue(Main.kt:12)
at BaseImpl.print(Main.kt:9)
at Derived.print(Main.kt)
at Main3Kt.main(Main.kt:22)
which is the cleanest way to refactor this snippet to specify in Derived
what should be used in BaseImpl.print()
?poohbar
01/02/2018, 7:28 PMval f1 = { it.length == 3} // T.() -> Boolean
val f2 = { length == 3} . // (T) -> Boolean
this does not look the same to meadam-mcneilly
01/03/2018, 12:38 AMtschuchort
01/03/2018, 12:30 PMMap
entry without iterating over the whole entry set? I need it to be able to change the associated value of a key repeatedly without having to find the key in the map again every time.kassim
01/03/2018, 1:32 PMval example = listOf()
won’t compile, I must write val example = listOf<Any>()
Marc Reichelt
01/03/2018, 4:22 PMtschuchort
01/03/2018, 5:40 PMpoohbar
01/04/2018, 2:35 AMkotlin/reflect/jvm/internal/KotlinReflectionInternalError
when running the app from jar, but the app works from intellijMarcus Fihlon
01/04/2018, 9:12 AMclass RuntimeExceptionMapperTest : StringSpec() {
init {
val mapper = RuntimeExceptionMapper()
"ConcurrentModificationException should be mapped to CONFLICT (409)" {
val e = ConcurrentModificationException("Test") // throws exception - why?
mapper.toResponse(e).status shouldBe CONFLICT.statusCode
}
}
}
I use Kotlin 1.2.10 with KotlinTest 2.0.7 and have no idea, why the exception is thrown. I just want to create an exception object, not throwing it…damian
01/04/2018, 11:33 AMclass
of my generic? my construct looks like this:
abstract class Base<T: Parent> {
val something: MyGenericClass<T>(T::class.java)
}
but it says i cant use T
as reified type parameter and should use a class instead.snrostov
01/04/2018, 12:19 PMGT
cannot be inferred?
class A<T>(val t: T)
class B<T, out U: A<T>>(val t: T, val at: U)
fun <T> B<T, *>.withCapturedU(): B<T, A<T>> = this
private fun <FT> f(x: B<FT, *>) {
g(x) // ERROR, why?
g(x.withCapturedU()) // OK
}
private fun <GT> g(y: B<GT, A<GT>>) {
println(y)
}
cedric
01/04/2018, 7:57 PMjw
01/04/2018, 8:42 PMdeviant
01/04/2018, 10:07 PMexposed
or squash
? it seems both serve for same purposemolikto
01/05/2018, 4:37 AMphantom
01/05/2018, 10:30 AMmwerschy
01/05/2018, 4:28 PMCannot access 'clazz': it is private/*private to this*/ in 'Test'
?
class Test<out T>(private val clazz: Class<@UnsafeVariance T>) {
companion object {
fun test(test: Test<*>) = test.clazz
}
}
Making clazz
public or making T
invariant fixes the error but I'd prefer to avoid that. Companion objects should have access to private members so this should work as is.Sam
01/05/2018, 5:36 PMSam
01/05/2018, 5:36 PMziad
01/05/2018, 5:45 PMyole
01/05/2018, 5:57 PM