Slackbot
05/25/2021, 6:56 AMRajkumar Singh
05/25/2021, 11:04 AMList<List<Pacs>>
from a large List<Pacs>
. I created a function buildGroupedList
that takes List<Pacs>
as argument.mzgreen
05/25/2021, 11:53 AMclass Foo(val bar: Boolean)
var foo: Foo? // initialized somewhere in the code
fun test(): Boolean {
return foo != null && !foo!!.bar // doesn't look nice
}
How can I make the expression in test() method nicer assuming I can't make foo non nullable?Pablo
05/25/2021, 12:50 PMinterface StringProvider {
operator fun get(key: String): String
fun getString(key: String): String
....
}
And I have a class that contains the key but can not add this StringProvider
dependency how can I add this block to the constructor so I can get the key?
class Foo {
....
var age: String
var weigh: String
fun getExample(provider: (String) -> String) : Foo {
age = provider["ageprovider"]
weigh = provider["weighprovider"]
}
}
So in my class that I have a object of StringProvider
I send just the StringProvider
Vijayakumar M
05/25/2021, 1:47 PMdead.fish
05/25/2021, 3:51 PMiamthevoid
05/26/2021, 6:25 AMtry { } catch (e: Exception) { }
block that returns null
on exception (in stdlib)? Something like runCatching { }
, but without unwrapping.nisrulz
05/26/2021, 11:50 AM@OptIn
annotation. I am looking for an enhancement and would like to know if it even makes sense before opening an issue.christophsturm
05/26/2021, 12:44 PMspand
05/26/2021, 1:09 PMfun <R> foo(block: () -> R): R = TODO()
val fooName = ::foo.name
ribesg
05/26/2021, 1:49 PMnullableBoolean == true
2️⃣ nullableBoolean ?: false
user
05/26/2021, 3:42 PME.Kisaragi
05/26/2021, 5:48 PMrnett
05/26/2021, 7:51 PMMjahangiry75
05/27/2021, 7:56 AMimplementation project(":module")
in kotlin build scriptPablo
05/27/2021, 8:13 AMdata class Foo (val id: String, val name: String)
val fooList = listof<Foo>(Foo("1","foo1"),Foo("2","foo22)
Imagine I get this fooList
as a parameter and I want to update this list, do I need to do a clone
of the list and then a copy
of the data class
and update there the values?Paul Woitaschek
05/27/2021, 8:36 AM(0F/0F).coerceIn(0F,1F)
NaN
?Denys
05/27/2021, 2:46 PMkschlesselmann
05/27/2021, 4:00 PM<http://logger.info|logger.info> { "Some expensive $string" }
. Now there's structured logging as well with https://github.com/logstash/logstash-logback-encoder. It would be great if I could use the lazy evaluated logging approach with multiple arguments as well.
I came up with something like
private fun KLogger.infoWithVarargSupplier(
vararg arguments: () -> Any,
message: () -> String,
) {
if (isInfoEnabled) {
info(
message.invoke(),
*arguments
.map { it.invoke() }
.toTypedArray(),
)
}
}
and now I'd like if there would be any huge performance impact in using a function like this. I tried creating a JMH benchmark but the results look suspicious … any suggestions?William Smyth
05/27/2021, 5:07 PMHey All, silly newbie question here:Would Kotlin be a good choice for developing an app that is essentially performing calculator and timer functions against data entries and automatic updates? ## App Basics • Mobile App: (IOS & Android, preferably) •
v1
isn't expected to be much more than form pages for manual data entry and then a fairly simple algorithm against said data to produce a suggested number based on the input. During these events it will also kick off a timer to track the time since the input for later calculations. My v1
architecture will likely be locally stored data (haven't decided on database type), which can be copied/saved to cloud storage providers (e.g., Google Drive, Box, OneDrive, etc.). The data needs to be encrypted for privacy. I'd like to collect anonymous usage statistics with zero private information and have that sent back to a web service that I intend to write—haven't decided on an event queue/bus service yet but will likely use something opensource initially.
I ask because I believe a more native language would probably perform faster calculations and more reliable timers. Which is something I believe will become very important with later feature releases that are using more algorithms, and potentially AI/ML. (edited)Daniel
05/27/2021, 5:39 PMclass MapboxState constructor(override val coroutineContext: CoroutineContext): CoroutineScope {
private val mapChan = Channel<MapboxMap>(1)
val map = async {
mapChan.receive()
}
internal suspend fun registerMap(newMap: MapboxMap) {
if (map.isCompleted) {
throw IllegalStateException("MapState already registered to a MapboxMap")
}
mapChan.send(newMap)
}
}
Slackbot
05/27/2021, 8:21 PMSimon Kågedal Reimer
05/27/2021, 8:33 PMPaul Griffith
05/27/2021, 10:58 PMget
makes sense, but some of the data I have to pass in are arrays. I can manually 'up' cast to Any, but I'm curious if there's any other possibility.mario
05/28/2021, 6:46 AMMichael Böiers
05/28/2021, 12:44 PMval list = listOf(1, 2)
if (list is MutableList) list.add(3)
https://pl.kotl.in/_jfhJy6is
Why is that? I mean, I get that the list is immutable, but why then can it be cast to MutableList?Atchay Varma
05/28/2021, 1:18 PMzain
05/28/2021, 2:44 PMbackButton.setOnLongClickListener {
GlobalScope.launch(Dispatchers.Main) {
if (backButton.isPressed) {
viewPager.setCurrentItem(viewPager.currentItem - 1, true)
delay(500)
}
}
true
}
zain
05/28/2021, 3:35 PMTodd
05/28/2021, 5:12 PMthis::class
using a normal parameter.Todd
05/28/2021, 5:12 PMthis::class
using a normal parameter.Casey Brooks
05/28/2021, 6:27 PMTodd
05/28/2021, 7:49 PM