https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
announcements
  • a

    aljosa

    03/27/2020, 9:51 AM
    is there an UI project which supports hot reload (similar to react native or flutter)?
    r
    n
    • 3
    • 3
  • s

    Slackbot

    03/27/2020, 10:58 AM
    This message was deleted.
    l
    • 2
    • 1
  • b

    Bulat Mukhutdinov

    03/27/2020, 1:10 PM
    Hi! I have a project with multiplatform gradle module and jvm application module. Now I want to create one more which would be used in the both ones. I am also making this new module multiplafrom and impotr it in the both gradle modules. In compilation time everything is fine but in runtime jvm module errors with java.lang.NoClassDefFoundError https://github.com/BulatMukhutdinov/Challenger Does anyone faced this issue?
    a
    • 2
    • 1
  • n

    nwillc

    03/27/2020, 2:54 PM
    Just a plug from a random dev - tried the NativeScript Kotlin support last night - within 30 min, with an Mac and iPhone, I was seeing my Kotlin app on a iPhone - pretty sweet.
    🎉 1
    b
    • 2
    • 3
  • a

    Ardian

    03/27/2020, 8:32 PM
    Hi everyone! I am trying to open a Maven Kotlin project on Eclipse, which contains .kt and .kts files. I have no problem with .kt files but when I tried to load a .kts file into the editor, Eclipse isn't able to open it. If you notice on the screenshot, there are 2 tabs: one for a .kt file and the other tab only has the close icon on the tab (this is the .kts file I'm trying to load on Eclipse). I tried different versions of Eclipse but still no luck. Does anybody have the same issue? Any help is appreciated! I get that IntelliJ has awesome support for Kotlin. But this is for a project I'm working on at my company. Some people are just afraid for changes :) Thanks! Ardian
    d
    n
    • 3
    • 3
  • t

    Tim Malseed

    03/29/2020, 11:09 AM
    Hi all. For you Sqlite experts out there, is there an obvious, more concise representation of this:
    (SELECT count(*) FROM songs WHERE songs.albumId == albums.id AND songs.blacklisted == 0) as songCount
    s
    • 2
    • 1
  • t

    Tim Malseed

    03/29/2020, 11:10 AM
    What I’ve got is fine. I’m just wondering if I could be taking advantage of the
    count(distinct songs.id)
    (or whatever) syntax
    d
    • 2
    • 1
  • d

    df

    03/29/2020, 4:25 PM
    Hey there. I'm trying to use a method with the following signature
    inline fun <T> withLoggingContext(map: Map<String, String>, body: () -> T): T {
    invoking it like this
    withLoggingContext(browserInfo.toMap()) {
                    logger.warn { "Payment context provides no customer ip address" }
                }
    leads to following compilation error
    Error:(28, 13) Kotlin: None of the following functions can be called with the arguments supplied: 
    public inline fun <T> withLoggingContext(vararg pair: Pair<String, String>, body: () -> ???): ??? defined in mu
    public inline fun <T> withLoggingContext(pair: Pair<String, String>, body: () -> ???): ??? defined in mu
    public inline fun <T> withLoggingContext(map: Map<String, String>, body: () -> ???): ??? defined in mu
    Help is appreciated
    s
    • 2
    • 18
  • i

    iex

    03/29/2020, 7:12 PM
    is there a better way to do early exit from a function that this?
    val foo: Foo = optionalFoo ?: run {
        log.e("Not set, can't continue!")
        return
    }
    g
    s
    m
    • 4
    • 6
  • r

    Rodrigo Silva

    03/30/2020, 1:17 AM
    Hello everyone. I'm using DateTime - joda, and the postgresql database. When I send a date, it always records with one less day. Does anyone know why?
    d
    i
    +2
    • 5
    • 13
  • c

    Chills

    03/30/2020, 6:39 AM
    anyone taking this contest 😛 https://codeforces.com/blog/entry/75327
    b
    • 2
    • 1
  • b

    Benjamin Dobell

    03/30/2020, 7:32 AM
    I’m unable to retrieve a value from a
    MutableHashMap
    , using the keys retrieved from the map itself. Does anyone know how that could be possible? Attached is a screenshot of the seemingly contradictory debugger outputs. I should note, this isn’t just an issue with the debugger. In practice I’m inserting a key into a map, then almost immediately retrieving (further up the same call stack) using the exact same key and getting back
    null
    for the value corresponding to that key. There’s no multi-threaded access to this map etc.
    hashCode
    and
    equals
    are stable for said key. This is using Jetbrain’s runtime.
    m
    d
    • 3
    • 17
  • t

    tyrondis

    03/30/2020, 9:55 AM
    Hey everyone 👋 I am trying to write a "circular" iterator that works like so:
    val it = (1..3).circularIterator()
    it.next() // 1
    it.next() // 2
    it.next() // 3
    it.next() // 1
    // and so on...
    Any ideas how I can accomplish this? Is there already something similar in the stdlib?
    d
    • 2
    • 6
  • n

    Nikky

    03/30/2020, 1:09 PM
    can i somehow override setters of `var`s in a data class so i can sanity-check the data coming in ?
    m
    m
    • 3
    • 10
  • d

    dave08

    03/30/2020, 1:28 PM
    I don't know why I thought this was possible:
    data class Something(val somethingElse: SomethingElse, val andAnotherOne: AndAnotherOne)
    
    val something = Something(SomethingElse(), somethingElse.anotherOne)
    is there any reason why not (I mean being able to access the first val when initializing the second)? Why shouldn't this be like a regular `val`s inside the class?
    m
    a
    • 3
    • 12
  • v

    Volodymyr Chernyshov

    03/30/2020, 1:39 PM
    Hello. I’m porting RxPm library to Multiplatform based on Reaktive. Now I made Android part and trying to implement iOS, but I got strange behaviour: if I’m not using class or interface from rpm module in app-common such classes doesn’t includes to iOS framework. Maybe someone has such problem and can help me. Latest code available here https://github.com/vchernyshov/reaktive-pm/tree/reaktive-pm-mpp
    a
    • 2
    • 1
  • c

    CLOVIS

    03/30/2020, 2:09 PM
    Is there a Kotlin library to access and interact with Unix terminals?
    • 1
    • 1
  • h

    hdarritchon

    03/30/2020, 2:21 PM
    Hello, I was wandering how to make Kotlin Enum class serializable the good Way. I see some people using kotlinx.serializable with annotation @Serializable, somme others could use implementation avec the enum class like
    enum class Content(val value: String) : Serializable {
    In java, Enum is serializable by design but not in Kotlin. How would you do it ?
    d
    d
    • 3
    • 7
  • b

    Brendan Weinstein

    03/30/2020, 5:43 PM
    I just received a reminder email that there is 48hours left to submit a talk for KotlinConf. Should we still draft a submission or will there be a separate call for submissions later in the future?
    z
    • 2
    • 2
  • j

    Joshua

    03/30/2020, 6:24 PM
    Hey guys, just a general question.... Am I allowed to store a chat between user A and B for administrators so that they can review everything? Do you see any problems with this?
    m
    n
    +2
    • 5
    • 5
  • o

    Orhan Tozan

    03/30/2020, 7:19 PM
    Hey guys, I found this: https://github.com/Kotlin/kotlinx.collections.immutable. Does a PersistentList have the same performance as a MutableList? For example, I'm now using a MutableList for accumulating all the chat messages in a conversation inside a flow, thinking about going a more immutable way but scared of the performance hit since chat message lists can get big. Will a PersistentList have the same performance as a MutableList in these cases?
    b
    e
    • 3
    • 4
  • h

    Holger Steinhauer [Mod]

    03/30/2020, 8:19 PM
    Hey folks! The Kotlin User Group #berlin goes virtual - join our experiment with having a virtual meetup: https://www.meetup.com/kotlin-berlin/events/269715296/
    👍 2
    o
    l
    • 3
    • 4
  • e

    Ellen Spertus

    03/30/2020, 10:55 PM
    How could I refactor this code so squaring stops once the first square greater than 10 is found?
    println((1..100000).map { it * it }.filter { it > 10 }.first())
    (My real code doesn’t involve numbers or squaring, just a calculation that I want to stop computing when I get an acceptable result from
    map
    .)
    s
    a
    • 3
    • 4
  • i

    iseki

    03/31/2020, 12:36 AM
    Instead of KAPT and Compiler Plugins. Are there any way to write a codegen easily?
    d
    c
    d
    • 4
    • 3
  • n

    nkiesel

    03/31/2020, 1:02 AM
    We have tons of enums which encode a mapping from a numeric value (stored in a DB) to a name. I read about "enum with value" and I have some nice compact code like
    enum class Type(val value: Int) {
        INVALID(-1), SIMPLE(1), COMPLEX(2);
        companion object {
            private val map = values().associateBy(Type::value)
            fun fromInt(value: Int) = map.getOrDefault(value, INVALID)
            fun fromString(value: String) = try { valueOf(value) } catch (e: IllegalArgumentException) { INVALID }
        }
    }
    Is there a way to avoid repeating the "companion" part in every enum? Ideally, I would want
    enum class Type(code: Int) : Magic(code) { INVALID(-1), SIMPLE(1), COMPLEX(2); }
    with also some way to identify the INVALID obejct (or just assume it is always the value associated to
    -1
    )
    d
    • 2
    • 6
  • l

    LeoColman

    03/31/2020, 2:42 AM
    Does anybody's gradle glitches like this?
    n
    • 2
    • 8
  • i

    iseki

    03/31/2020, 4:48 AM
    Kotlin's
    val
    means
    immutable
    or `readonly`?🤔
    s
    • 2
    • 1
  • i

    iseki

    03/31/2020, 4:53 AM
    The value will be evaluation at runtime, but it's immutable.
    d
    l
    t
    • 4
    • 11
  • s

    Slackbot

    03/31/2020, 11:20 AM
    This message was deleted.
    :stackoverflow: 2
    :google: 1
    👎 1
    n
    a
    +2
    • 5
    • 8
  • h

    halirutan

    03/31/2020, 11:38 AM
    I'm sorry for my message above. Don't leave the kids on your computer while cooking lunch...
    👀 1
    🤣 2
    😂 4
    m
    a
    +2
    • 5
    • 7
Powered by Linen
Title
h

halirutan

03/31/2020, 11:38 AM
I'm sorry for my message above. Don't leave the kids on your computer while cooking lunch...
👀 1
🤣 2
😂 4
m

Martin Jinoch

03/31/2020, 11:48 AM
could have been much worse I guess ;)
a

arekolek

03/31/2020, 11:57 AM
you're referring to this one? :troll:
❓ 1
c

Christian Sousa

03/31/2020, 11:59 AM
The one that was above the one from Patrick is mine, not that one that he’s refering
i

iseki

03/31/2020, 12:11 PM
Something interesting I missed(
m

Martin Jinoch

03/31/2020, 12:30 PM
I was refering to the one Patrick's kid has sent.
h

halirutan

03/31/2020, 1:00 PM
Thank god they only managed to quote another message and send it. Was reading the message of Hadi and then saw my weird quote above. I thought "hmm, I didn't do that.."
😂 1
View count: 4