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
  • m

    Marcello Lelio Albano

    06/17/2021, 11:14 PM
    is there a channel where to ask help about writing a kotlin compiler plugin?
    r
    • 2
    • 3
  • m

    mzgreen

    06/18/2021, 6:25 AM
    I'm trying to do something like this:
    val list = listOf(1,2,3,4,5)
    when (list) {
        all { it < 10 } -> foo()
        any { it % 2 == 0 } -> bar()
        else -> baz()
    }
    but it doesn't seem to be possible and I'm not sure why.
    t
    v
    r
    • 4
    • 4
  • i

    igor.wojda

    06/18/2021, 8:58 AM
    Is there any other way to use property as delegate for another property?
    class Container {
        val view: View2 = View2()
        var onClickListener:(() -> Unit)? by view.onClickListener // does not work
    }
    
    class View2 {
        var onClickListener:(() -> Unit)? = null
    }
    v
    • 2
    • 12
  • s

    Slackbot

    06/18/2021, 11:12 AM
    This message was deleted.
    z
    d
    +2
    • 5
    • 6
  • q

    Quantum64

    06/18/2021, 1:19 PM
    Will @JvmInline on value classes only be present for single field classes? Will value classes with multiple fields compiled for Valhalla JVMs lack this annotation? Can we be sure that value classes annotated with @JvmInline will always have exactly one field even in future Kotlin versions?
    d
    e
    a
    • 4
    • 5
  • h

    Hexa

    06/18/2021, 5:53 PM
    Any ideas how can I parse this time with a format like this: 2017-07-24 03:45:26 +0000 UTC” I tried this but failed with “DateTimeParseException”
    import java.time.Instant
    import java.time.ZonedDateTime
    fun main() {
    val time = "2017-07-24 03:45:26 +0000 UTC"
    val parsed1: ZonedDateTime = ZonedDateTime.parse(time) // fails
    val parsed2: Instant = Instant.parse(time) // fails
    }
    }
    h
    d
    h
    • 4
    • 4
  • a

    Ayfri

    06/19/2021, 7:00 AM
    Hi, do you know any good library for doing simple but performant 3D graphics ? With a friend we want to try making a little Minecraft renderer to visualize our world, but I don't know what to use, he is on Linux and me on Windows so we need something multiplatform, and I guess that doing this with Compose will be great if we want to keep it simple and quick to develop ?
    👀 1
    c
    l
    r
    • 4
    • 12
  • a

    Alfred Lopez

    06/19/2021, 10:52 PM
    Hi all, does anybody know if there’s a pure Kotlin implementation of Jwt? One that doesn’t use java.security, nor javax.crypto, etc.?
    b
    • 2
    • 2
  • h

    hisham bin awiad

    06/20/2021, 12:21 PM
    any one faced EditText doesn't appear in preview window in android studio? note : when i set background it's work fine ? but i need it without background ! i have search and try many solutions but still ?
    :not-kotlin: 10
    u
    • 2
    • 1
  • w

    William Reed

    06/21/2021, 1:23 PM
    when using contracts, is there anything to guarantee that
    block
    isn’t called 0 or 2+ times?
    contract {
            callsInPlace(block, InvocationKind.EXACTLY_ONCE)
        }
    d
    • 2
    • 1
  • v

    Vijayakumar M

    06/21/2021, 2:34 PM
    Hello All! I seem to have an issue while working with nested coroutines with single threaded dispatcher. When I call scope.launch() inside another scope.launch(), the inner block wont get executed if I use single threaded dispatcher. Here is an example
    val dispatcher = ScheduledThreadPoolExecutor(1).asCoroutineDispatcher()
    
    val customScope = CoroutineScope(SupervisorJob() + dispatcher)
    
    customScope.launch{
    	//This block works fine.
    	customScope.launch{
    		//This block is not executing
    	}
    }
      However it woks fine If I change the dispatcher in the inner block. But In my case, I need to have the same dispatcher in both launches. Any help would be very much appreciated.
    z
    b
    • 3
    • 14
  • k

    Kirill Grouchnikov

    06/21/2021, 7:04 PM
    In the specific context of Compose, but a general higher level question on nested lambdas. Do you usually ignore this implicit shadowing warning, or do you do something like
    { change -> change.consumeDownChange() }
    for the inner block?
    n
    a
    d
    • 4
    • 8
  • w

    William Reed

    06/21/2021, 8:34 PM
    since something like this doesn’t work in kotlin
    var a = true
    var b = false
    when (a, b) {
       true, true -> ...
       true, false -> ...
       false, true -> ...
       false, false -> ...
    }
    is this the best alternative?
    when {
       a, !b -> ...
    }
    n
    d
    +2
    • 5
    • 9
  • p

    Peter Ertl

    06/23/2021, 8:38 AM
    since mapOf() on the jvm internally uses a LinkedHashMap which seems to keep order: so, does kotlin-mapOf() officially guarantee that the order of adding entries is preserved?
    d
    • 2
    • 2
  • l

    laith

    06/23/2021, 2:29 PM
    😂 4
    :kotlin-intensifies: 8
    ❤️ 18
    n
    l
    p
    • 4
    • 3
  • e

    eygraber

    06/23/2021, 3:54 PM
    Are there any bug fix releases planned for Kotlin 1.5.10? It seems like there were memory leaks introduced with Kotlin 1.5.0 and 1.5.10 didn't resolve all of them. From what I last saw on YouTrack, they are scheduled to be fixed in 1.5.30, but wouldn't things like that be a candidate for a bug fix release?
    s
    • 2
    • 2
  • j

    Josh Feinberg

    06/23/2021, 7:13 PM
    is there a way to debug why the kotlin daemon isn't working? we are getting:
    Could not perform incremental compilation: Could not connect to Kotlin compile daemon
    Could not connect to kotlin daemon. Using fallback strategy.
    since we upgraded from 1.4.31 to 1.5.10 but i'm not sure what to file in a bug or anything
    e
    a
    • 3
    • 4
  • m

    Matt Yokan

    06/23/2021, 10:03 PM
    In what cases will use of a Sequence be significantly slower than use of an Iterable with Sequence's current implementation that they cannot be iterated over multiple times?
    c
    e
    +2
    • 5
    • 28
  • s

    Sangmin Lee

    06/24/2021, 5:47 AM
    Hi. I’m making new class for variable type which has string value like below.
    class CustomFieldTypeA() {
        var value: String = ""
        private val charset: Charset = ACharset()
    }
    class CustomFieldTypeB() {
        var value: String = ""
        private val charset: Charset = BCharset()
    }
    
    data class TestData(
        var field1: CustomFieldTypeA = null,
        var field2: CustomFieldTypeB = null,
    )
    The reason to use CustomFieldType is to have charset for string. And I want to use this type in the same way to use String like below
    // for setter
    val obj = TestData()
    obj.field1 = "hi type 1"
    obj.field2 = "hi type 2"
    // for getter
    val str = obj.field1
    print(str) // hi type 1
    Is there any way to do like this? (maybe using delegate?)
    t
    e
    • 3
    • 10
  • s

    Stanislav Kral

    06/24/2021, 8:17 AM
    Hello guys, is there any way to run stop mapping the items when the first non null item is found? Doing that in a simple for loop would be obvious, but I would like to make use of kotlin collection operators. This question applies to the
    ConfigValidator.validate
    method. Any other comments or possible improvements to the code below are also welcome. Thanks!
    class ConfigValidator(private val configRules: List<Rule>) {
        abstract class Rule {
            abstract fun validateConfig(model: InitModel): RuleViolation?
        }
    
        fun validate(model: InitModel) = configRules.map {
            // !!! is there any way to make this stop mapping items when the first RuleViolation is found? !!!
            // this method needs to return "RuleViolation?"
            it.validateConfig(model)
        }.firstOrNull()
    
        class SimpleRule1(...) : Rule() {
            override fun validateConfig(model: InitModel): RuleViolation? =
                model.items.firstOrNull {
                    // some condition for model item
                }?.let {
                    RuleViolation(1, "Rule violation description")
                }
        }
    
        class SimpleRule2(...) : Rule() {
            override fun validateConfig(model: InitModel): RuleViolation? =
                model.items.firstOrNull {
                    // some condition for model item
                }?.let {
                    RuleViolation(2, "Rule  2 violation description")
                }
        }
    
        class RuleViolation(val code: Int, message: String) : Exception(message)
    }
    e
    m
    • 3
    • 7
  • m

    Mjahangiry75

    06/24/2021, 11:57 AM
    What pro book do you suggest about kotlin? I know kotlin well, but I want to know it better.
    c
    g
    +2
    • 5
    • 8
  • m

    Matt Anger

    06/24/2021, 5:37 PM
    Anyone else seeing failures with gradle publishing and 1.5.20?
    t
    a
    • 3
    • 6
  • e

    eygraber

    06/25/2021, 5:03 AM
    Getting this new warning after updating to Kotlin 1.5.20:
    JvmField cannot be applied to a property of an inline class type. This warning will become an error in further releases
    I didn't see this mentioned anywhere in the release notes (or the GitHub release). Is there something pointing to this?
    a
    • 2
    • 6
  • m

    MTM123

    06/25/2021, 9:23 AM
    Hello! I'm not sure if this has been asked before but I have found few issues on YouTrack but they haven't really gone further than just that. Anyways, currently in Kotlin there is no way to assign integer value to Double type variables or use integer in place where Double is expected instead you have to explicitly add a decimal point. Is there anything planned regarding this or is this open for contributors maybe?
    g
    • 2
    • 4
  • k

    Kasule Moses

    06/25/2021, 4:55 PM
    How can I best connect ktor to the postgresql database and then my Android project
    h
    j
    • 3
    • 8
  • v

    Vivek Modi

    06/25/2021, 10:54 PM
    Hi To improve my Kotlin skills, I'm looking for an open source project I could be able to contribute to any suggestions ?
    b
    a
    • 3
    • 6
  • s

    Sam Garfinkel

    06/26/2021, 1:41 AM
    Question about value classes (I'm familiar with the old inline classes but it has been a while): I was under the impression value classes, like inline classes, behave with respect to the compiler like the wrapped class. So why is the following invalid?
    @JvmInline
    value class Bar(
       val foo: Foo
    )
    
    fun Foo.doSomething() {
    }
    
    ERROR HERE >>> Bar(Foo()).doSomething()
    l
    r
    n
    • 4
    • 8
  • a

    Akshat Sharma

    06/26/2021, 6:34 AM
    Hi team, Kotlin beginner question here, created a new package in Kotlin Project, but its not allowing me to use Kotlin basic function such as println,
    r
    h
    g
    • 4
    • 8
  • v

    Viet Nguyen Tran

    06/26/2021, 7:17 AM
    hi, do you have lag with Android Studio on M1 Mac? I’ve just installed Android Studio on M1, and feel performance not good as with Intel Mac.
    :not-kotlin: 1
    g
    j
    +2
    • 5
    • 6
  • a

    Akshat Sharma

    06/26/2021, 7:27 AM
    Any Kotlin Pro available for 15 min call? Have some basic beginner questions around IntelliJ
    g
    • 2
    • 2
Powered by Linen
Title
a

Akshat Sharma

06/26/2021, 7:27 AM
Any Kotlin Pro available for 15 min call? Have some basic beginner questions around IntelliJ
g

gildor

06/26/2021, 8:14 AM
This slack is not a free phone support service, be respectful to other 40 thousands people in this channel and formulate your question and post it here if it Kotlin specific, if you need personal consultation it's not a right way to search for it There is also #getting-started channel
👍 2
✅ 1
➕ 2
:nope: 1
a

Akshat Sharma

06/26/2021, 9:47 AM
Thanks @gildor for your feedback. I will surely be careful in the future. My intention was to find someone who is happy to help.
View count: 18