Bart
08/28/2021, 7:58 PMImplementation("org.ktorm:ktorm-core:${ktorm.version}")
Unfortunately its ending with error
Unresolved reference: ktorm
Any idea why? Following ktorm documentation it should work in this way :(Hamza GATTAL
08/28/2021, 9:35 PMErdem Tuna
08/30/2021, 9:35 AMbuild.gradle.kts
) where I can input custom arguments when running?
Actually, as I understand, I need to define new task that can take command-line input and invoke the main.acoconut
08/30/2021, 12:47 PMdata class Book (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long? = null
)
is way easier to read than:
data class Book (
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) val id: Long? = null
)
What do you all use if anything?Gopal S Akshintala
08/31/2021, 5:43 AMCollectionsKt
method directly in java and run this in a unit test. However this static import is causing this exception
import static kotlin.collections.CollectionsKt.chunked;
However, if I use CollectionsKt.chunked(…)
without the static import, I don’t get this exception:
java.lang.IllegalAccessError: failed to access class kotlin.collections.CollectionsKt___CollectionsKt from class billing.batch.invoice.services.tax.TaxIntegrator (kotlin.collections.CollectionsKt___CollectionsKt and billing.batch.invoice.services.tax.TaxIntegrator are in unnamed module of loader org.powermock2.core.classloader.javassist.JavassistMockClassLoader @5443d039)
maarten ha
08/31/2021, 3:15 PMSaharath Kleips
09/01/2021, 5:59 PMvalue class Box(val str: String)
val letters: List<String> = listOf("A","B","C",...)
val boxes: List<Box> = letters.map(::Box)
val backToLetters: List<String> = boxes.map(Box::str)
Are there any costs associated with moving between a List<String>
and List<Box>
and vice versa?Mahir Chowdhury
09/01/2021, 8:19 PMMahir Chowdhury
09/01/2021, 8:19 PMLazyRow(
state = listState,
modifier = Modifier.fillMaxWidth().padding(50.dp, 0.dp)
.pointerInput(Unit) {
detectHorizontalDragGestures { _, dragAmount ->
coroutineScope.launch {
if (dragAmount < 0) {//scroll right
listState.animateScrollToItem( listState.firstVisibleItemIndex+2)
} else if (dragAmount > 0) {//scroll left
listState.animateScrollToItem(listState.firstVisibleItemIndex -1)
}
}
}
},
horizontalArrangement = Arrangement.spacedBy(10.dp)
)
This is what I have in the parameters for LazyRowJames Whitehead
09/02/2021, 1:00 AMJérémy CROS
09/02/2021, 9:45 AMlistOf(element0) + listOfElements + elementLast
But I’m not sure if there are more efficient / maybe clearer options available ?Erik
09/02/2021, 3:27 PMfun <T> Array<out T>.asList(): List<T>
• fun <T> Array<out T>.toList(): List<T>
By signature, they are identical. So the behaviour must define the naming difference.
Likewise, there exists a fun <T> Array<out T>.asIterable(): Iterable<T>
but not toIterable
.
Then there are all kinds of variants that use names like mapTo
.
When do you use as
, to
, mapTo
or something else?Erik
09/02/2021, 3:31 PMOrNull
variant. Or in the coroutines lib, it's conventional to either write a suspend fun foo()
or write a non-suspending extension fun CoroutineScope.foo()
, but not suspend fun CoroutineScope.foo()
. And likewise, suspend fun foo(): Flow<Bar>
usually doesn't make sense, but fun foo(): Flow<Bar>
is more conventional.
It's probably a good idea to use the same naming conventions in your own Kotlin APIs.GUIGAL Allan
09/03/2021, 4:49 PMoperator fun getValue(thisRef: Any?, property: KProperty<T>): T {
Ayfri
09/03/2021, 7:33 PMAlexander Suraphel
09/04/2021, 3:11 PMvar animals: List<Animal> = ArrayList<Dog>()
where Dog
-> Animal
The following won’t compile in Java:
List<Animal> animals = new ArrayList<Dog>();
Stylianos Gakis
09/05/2021, 8:24 AMmap
filter
associate
and whatnot, but I wanted to debug it. In Java streams we can use the “trace current stream chain” while debugging, but it seems to be greyed off in Kotlin.
If I use the asSequence
I get this functionality, but is this the only way? Sometimes a sequence doesn’t make sense to use, and using it just to enable this debugging functionality feels wrong, is this my only option?Muhammet Emin Gündoğar
09/05/2021, 10:39 AMigor.wojda
09/06/2021, 6:16 AMCollection
type? Fine / Not Fine? and Why?
val modifiers: Collection<Modifier> = emptyList()
nilTheDev
09/06/2021, 2:02 PMequals/hashcode
method implemented by default.
But it turns out,
class SomeClass(val a: String)
fun main(){
val someClass1 = SomeClass("abcd")
val someClass2 = SomeClass("abcd")
println(someClass1 == someClass2) // this code is also valid
}
==
is also supported in regular classes.
How does it behave?
Is ==
is same as ===
in case of non-data classes?The Monster
09/06/2021, 4:00 PMZyle Moore
09/06/2021, 8:29 PMThe Monster
09/06/2021, 11:14 PMinline fun test(crossinline callback: () -> Unit){
callback()
}
The doc says:
some inline
functions may call the lambdas passed to them as parameters not directly from the function body, but from another execution context, such as a local object or a nested function.
which I understood as:
an inline
function is not allowed to call the crossinline
parameter directly in its scope, ...
But why does the code snippet works and I was able to call callback()
directly? Does the doc meant to say that you can call the crossinline
argument directly and within another local scope as well?Chachako
09/07/2021, 1:17 AMnew.foo.bar.foo.bar.baz
merged to new.foo.bar.baz
foo.bar.foo.bar.qux
merged to foo.bar.qux
but foo.bar.break.foo.bar
does not merge 🤯Simon Lin
09/07/2021, 5:56 AMHashMarkOrderComparator
to put #
in the last and I also need String.CASE_INSENSITIVE_ORDER
Comparator.
How can I combine this two Comparator
?Chachako
09/07/2021, 9:11 AMremoveSuffix
or removePrefix
?Muhammet Emin Gündoğar
09/07/2021, 10:11 AMWilliam Reed
09/07/2021, 4:00 PMelect
09/07/2021, 4:04 PMAccessing super members from public-API inline function is deprecatedwhy?
Muhammet Emin Gündoğar
09/08/2021, 3:19 PMMuhammet Emin Gündoğar
09/08/2021, 3:19 PMPaul Griffith
09/08/2021, 3:24 PM