Bernhard
02/02/2019, 8:19 AMCircuitRCAY
02/02/2019, 10:09 AMfun main(args: Array<String>) {
val p1 = Pair(1, 2);
val p2 = Pair(3, 4);
val p3 = Pair(p1, p2);
val (simple, destructuring) = p1
//val ((nested, _), (destructuring, _)) = p3;
}
Hope you get back to me, thanksHexa
02/02/2019, 3:35 PMpablisco
02/02/2019, 4:01 PMtapchicoma
02/02/2019, 5:05 PMitem1
is highlighted with "Cannot infer a type for this parameter. Please specify it explicitly"?
Is there a way to modify someWrapper()
to remove this error?mhamade
02/03/2019, 2:52 AMNikky
02/03/2019, 3:40 AMgit diff
process) and turn it into colored html output?Joe
02/03/2019, 6:38 AMit::class.memberProperties.filter { prop -> prop.name == propertyName }.first().get(it)
but getting the following compiler error:
Out-projected type 'KProperty1<out DataClass!, Any?>' prohibits the use of 'public abstract fun get(receiver: T): R defined in kotlin.reflect.KProperty1'
using it::class.java.getMethod("get${propertyName.capitalize()}").invoke(it)
appears to work, but it seems like there should be a way to do this through KClass directly (and avoid having to generate the getter method name)?tipsy
02/03/2019, 9:30 AMError:Kotlin: [Internal Error] java.lang.IllegalStateException: Backend Internal error: Exception during code generation
Cause: Back-end (JVM) Internal error: wrong code generated
org.jetbrains.kotlin.codegen.CompilationException Back-end (JVM) Internal error: Couldn't transform method node:
anyone know what's up?natpryce
02/03/2019, 12:56 PMdf
02/03/2019, 7:43 PMDavide Giuseppe Farella
02/03/2019, 8:57 PMchild::childNodeBlock
?natpryce
02/04/2019, 8:15 AMCzar
02/04/2019, 8:49 AMof(a, b, c)
, where of
was a static import of ImmutableList.of
, ImmutableSet.of
etc.
You always had to look at the imports to understand the code.
Arguably that's a naming/misunderstood intention problem though, Google Collections' team obviously intended *.of
not to be statically imported.Bernhard
02/04/2019, 8:57 AMdimsuz
02/04/2019, 10:49 AMsealed class Outer {
data class Inner1(val value: Int) : Outer()
data class Inner2(val value: String) : Outer()
}
typealias OuterAlias = Outer
fun main() {
val i = OuterAlias.Inner1(3) // gives an error "Unresoved reference: Inner1"
}
If typealias is just an alias the above should be possible I guess.dave08
02/04/2019, 11:39 AMfind { }
and firstOrNull { }
on Iterable<T>
in the stdlib?Bernhard
02/04/2019, 1:52 PMguppyfaced
02/04/2019, 4:27 PMMicah Church
02/04/2019, 9:37 PMkevinherron
02/04/2019, 11:16 PMMarc Knaup
02/05/2019, 7:42 PMopen
to its own module only but not to "the public"?Robert
02/05/2019, 9:27 PMappend
but no method prepend
, that does not make much sense to me. Anyone knows why there's none?frellan
02/05/2019, 9:58 PMmap
stuff instead but I can’t figure out how to do this. I’m essentially looping over a sequence and I want to place things into three different lists, like partition
but for three output collections instead of two. Is there some general function or a combination that can do this?
val success: MutableList<String> = ArrayList()
val failed: MutableList<String> = ArrayList()
val ignored: MutableList<String> = ArrayList()
for (string in strings) {
val result = doStuff(string)
when {
result != null -> success.add(ingredient)
other condition -> ignored.add(string)
else -> failed.add(string)
}
}
Andrew Gazelka
02/06/2019, 12:16 AMLukretsiy
02/06/2019, 6:40 AMdata class Lol {val Kek: String)
Currently, Kek
will be mapped to kek
, but I want to preserve it as Kek
marcinmoskala
02/06/2019, 12:01 PMDias
02/06/2019, 2:09 PMrunBlocking {}
in junit tests and you have assertEquals()
as the last call (or any kotlin test assertion) it doesn't work, because tests should have Unit
return type, but since asserEquals
returns stuff, junit doesn't pick up the test. What can I do? I can just put Unit
in the end of the call, but it does't look goodaltavir
02/06/2019, 2:21 PMkarelpeeters
02/06/2019, 10:13 PMtoReplace
in list
and replace it with replacement
? Because the code doesn't require an exact match right now.karelpeeters
02/06/2019, 10:13 PMtoReplace
in list
and replace it with replacement
? Because the code doesn't require an exact match right now.Daniel
02/06/2019, 10:19 PMtoReplace
is part of the list
karelpeeters
02/06/2019, 10:21 PMreplaceInList(listOf(1,2,1,5,2), listOf(1,5,2), listOf(6))
Daniel
02/06/2019, 10:22 PMkarelpeeters
02/06/2019, 10:23 PMDaniel
02/06/2019, 10:26 PM1, 2
, then + 6
and the last sublist, yeah would throw an index out of bounds exception, I simplified a bit too much, it seems. Thank you for your reply!karelpeeters
02/06/2019, 10:27 PMDaniel
02/06/2019, 10:30 PMlistOf(1,2,3,4)
replace listOf(2,3)
with listOf(6,7,8)
or listOf(6)
and should end up with listOf(1,6,7,8,4)
or listOf(1,6,4)
so any replacement should be possible.
For the toReplace
you can be sure that it is part of the list
karelpeeters
02/06/2019, 10:32 PMtoReplace
in list
because it only checks the first and last positions. The size of toReplace
and the matched part of list
don't even have to match.Daniel
02/06/2019, 10:54 PMnkiesel
02/07/2019, 12:43 AM[1,1,1,2,2,2]
and you want to replace [1,2]
with [3]
. I think you want [1,1,3,2,2]
but your code would produce [3,2,2]
instead. But even that is not good enough because replaceInList(listOf(1,2,3,4,5), listOf(4,2), listOf(0))
would produce [1,2,3,0,3,4,5]
and replaceInList(listOf(1,2,3,4,5),listOf(1,5),listOf(0))
would produce [0]
fun replaceInList(list: List<Int>, toReplace: List<Int>, replacement: List<Int>): List<Int> {
val i = list.windowed(toReplace.size).indexOfFirst { it == toReplace }
return if (i == -1) list else list.take(i) + replacement + list.drop(i + toReplace.size)
}