Moritz Post
11/29/2021, 10:45 AMCharacter.getNumericValue()
? It would be useful in kmp but i can't seem to find one.Alex Ostrovsky
11/29/2021, 2:59 PMNick
11/29/2021, 9:29 PMfreeCompilerArgs
working. I’m still getting errors/warnings with what I have tried below. This is in the build.gradle
of a module.
android {
kotlinOptions.freeCompilerArgs += compilerArgs
}
and
tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.freeCompilerArgs += compilerArgs
}
}
…. more in thread 🧵Colton Idle
11/30/2021, 3:50 AMLeonardo Borges
11/30/2021, 10:54 AMJan
11/30/2021, 1:26 PMException in thread "DefaultDispatcher-worker-3" java.lang.ClassCastException: class kotlin.reflect.jvm.internal.KTypeImpl cannot be cast to class kotlin.jvm.internal.TypeReference (kotlin.reflect.jvm.internal.KTypeImpl and kotlin.jvm.internal.TypeReference are in unnamed module of loader 'app')
at kotlin.jvm.internal.ReflectionFactory.mutableCollectionType(ReflectionFactory.java:107)
at kotlin.jvm.internal.Reflection.mutableCollectionType(Reflection.java:196)
at io.github.jan.discordkm.api.entities.interactions.commands.builders.ChatInputCommandBuilder.build$DiscordKM(ApplicationCommandBuilder.kt:211)
at io.github.jan.discordkm.api.entities.containers.CommandContainer.create(CommandContainer.kt:29)
at io.github.jan.therealbot.MainKt$main$$inlined$on$default$4.invokeSuspend(DiscordWebSocketClient.kt:171)
at io.github.jan.therealbot.MainKt$main$$inlined$on$default$4.invoke(DiscordWebSocketClient.kt)
at io.github.jan.therealbot.MainKt$main$$inlined$on$default$4.invoke(DiscordWebSocketClient.kt)
at io.github.jan.discordkm.api.events.EventListenerKt$EventListener$1.onEvent(EventListener.kt:21)
at io.github.jan.discordkm.api.events.EventListener$DefaultImpls.invoke(EventListener.kt:16)
at io.github.jan.discordkm.api.events.EventListenerKt$EventListener$1.invoke(EventListener.kt:20)
at io.github.jan.discordkm.api.entities.clients.DiscordWebSocketClient$handleEvent$2$1$1.invokeSuspend(DiscordWebSocketClient.kt:101)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Colton Idle
11/30/2021, 7:20 PMsealed class GenericActionType {
class Dialer(phoneUri: String) : GenericActionType()
class Browser(url: String) : GenericActionType()
object Unknown : GenericActionType()
}
thana
12/01/2021, 11:07 AMusername
part of the primary ctor and without changing its name?Pratik Khandelwal
12/01/2021, 12:04 PMgetCurrentSubscription
method returns a `Subscription?nullable type. Doing a
.let` makes the it
also type of Subscription?
. I though .let should pass on a non-null Subscription
inside.
Now my cancelSubscription
method expects a non-nullable it.id
which is causing issues. What am I missing here?
getCurrentSubscription.invoke(customerId).let {
cancelSubscription.invoke(it.id, cancelled).let { subscription ->
subscriptionApiMapper.fromDomainModel(subscription)
}
}
elect
12/01/2021, 12:54 PMtypealias BatchSize = 100
typealias Height = 40
typealias Width = 50
fun getFirst(
input: Tensor<[BatchSize, Height, Width]>
): Tensor<[Height, Width]> {
...
}
typealias
integer values or square brackets in type parameters..?Ahmed Hassan
12/01/2021, 1:04 PMif (nullableVarParent?.nullableValChildOne == null
|| nullableVarParent?.nullableValChildTwo == null)
return
funcEx(
nullableVarParent?.nullableValChildOne!!,
nullableVarParent?.nullableValChildTwo!!
)
...
I had a discussion with a college about how unsafe the previous code is, to use (!!) operator even after "if condition".
He is totally convinced that the mutable parent is impossible to be null after the if condition since we don't use threads in this area.
His words are some how believable but since everyone in the world has been saying to avoid suppression (!!) in all cases, I wanted to make sure. what do you think might be dangerous about this?Ahmed
12/01/2021, 3:18 PMs = "string"
list = [s * 10]
basically, I just want to create a list of objects each of them is the same string actuallyRichard Gomez
12/01/2021, 9:53 PMcompiles
method compiles without issue, but if I save the expression to a variable instead of returning it, it complains about a type mismatch.hoang
12/02/2021, 8:46 AMAyfri
12/02/2021, 3:45 PMval versionDate = "May 5, 2009"
val formattedDate = SimpleDateFormat("MMM d, yyyy").parse(versionDate)
println(formattedDate)
What am I doing wrong ?Colton Idle
12/03/2021, 3:06 PMJesse Hill
12/03/2021, 4:18 PMString.split
functionality and came across this situation which made me curious. I found that running this: "hello".split("")
produces this ["", "h", "e", "l", "l", "o", ""]
. I didn’t expect for there to be empty strings on the start and end of the returned list only that the list would be made up of each character from the original string. To clarify, I’m not asking about the best way to iterate characters in a string or how to get them into a list, just curious about the implementation of split
with an empty separator and why the empty strings were appended to each end of the resulting list?Filipe Duarte
12/04/2021, 1:02 PMEdoardo Luppi
12/04/2021, 1:48 PMAlex
12/04/2021, 3:59 PMTwoClocks
12/04/2021, 8:02 PMDuration
it seems to be missing .between
? So I need to use Java's, in which case I can't use Kotlin's because importing both doesn't work? What am I missing?Colton Idle
12/04/2021, 8:05 PMfun Long.euroCentsToString(): String {
val format = NumberFormat.getCurrencyInstance()
format.maximumFractionDigits = 2
format.currency = Currency.getInstance("EUR")
return format.format(this/100)
}
If I call 849999L.euroCentsToString()
I get a result of €8,499.00
I thought what I'd get is €8.499,99
So Basically three issues:
1. I thought europeans use .
to separate thousands from hundreds
2. I thought europeans use ,
to designate the start of fractional (cents)
3. I thought I'd see 99 as the cents and not 00.Ayfri
12/05/2021, 2:58 PMval data = readFile("day1.txt")
val pairs = data.trimEnd().split("\n").zipWithNext().toMap()
val result = pairs.count { a ->
return@count a.key == a.value
}
pairs.forEach { println("key=${it.key}, value=${it.value}") }
println(result)
I don't get the key=something
part in my consoleDraget
12/05/2021, 8:41 PMholgerbrandl
12/05/2021, 10:51 PMequals
). E.g. how to transform
listOf("A", "A", "B", "C", "C", "C", "C", "A", "A")
// to
listOf("A" to 2, "B" to 1, "C" to 4, "A" to 2)
Marc Javier
12/05/2021, 10:59 PMMinsoo Cheong
12/07/2021, 9:15 AMwhen
statements' break OCP(open-closed-principle) ?
I saw the new sealed when compiler feature on Kotlin 1.6.0 and shared it to my team, thinking we could use it, but there was an opinion that this kind of logic breaks the ocp rule because,
If you add new inheritors to the sealed class(or interface), you would have to change all the when statements that take that sealed class(which is the parent class) and thus, ocp is broken
Would this be true? We agreed that the oop rules were made before sealed classes/interfaces were introduced and this might be the "trend" of programming languagues, but still some are hesitant to use it.
Any kind of related opinion & reading material is welcome to be shared,,
thanks!Pitel
12/07/2021, 9:23 AM10..0
creates empty range, and I have to change it to 10 downTo 0
. But I don't want to bother with it. I would expect 10..0
to do it automaticaly.Alex K
12/07/2021, 8:27 PMresources.getStringArray(R.array.listOfNorthDishesArray).toMutableList()
Nick
12/07/2021, 11:40 PMclass MyViewModel : ViewModel() {
sealed class SelectedFolder {
object Unselected : SelectedFolder()
data class Selected(val id: String) : SelectedFolder()
}
}
or
2️⃣
private sealed class SelectedFolder {
object Unselected : SelectedFolder()
data class Selected(val id: String) : SelectedFolder()
}
class MyViewModel : ViewModel() {