https://kotlinlang.org logo
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
  • s

    Sourabh Rawat

    10/26/2020, 10:07 AM
    Following does not work:
    @Serializable
    data class ApiResponse<T>(
        val result: T? = null,
        val error: ApiError? = null
    )
    
    call.respond(ApiResponse(result = gameEngine.newGame()))
    But this does:
    @Serializable
    class Foo(val bar: ApiResponse<String>)
    
    call.respond(Foo(ApiResponse(result = gameEngine.newGame())))
    Using ktor + serialization My question is why? and how can i achieve the first one. I am getting
    Serializer for class 'ApiResponse' is not found
    for 1st approach
    m
    m
    • 3
    • 7
  • r

    rkeazor

    10/26/2020, 11:13 AM
    Hey is there a link to the Kotlin AMA session that happen today?
    u
    • 2
    • 1
  • n

    Nir

    10/26/2020, 2:05 PM
    I'm probably missing an obvious place to look, but I've seen discussion recently of a talk that was given about the future of Kotlin, discussing decorators, support for immutable classes, other things, I can't seem to find a link to this talk. Does anyone have the link handy? (Or can tell me where I should be looking for it?)
    b
    r
    • 3
    • 3
  • b

    Big Chungus

    10/26/2020, 5:07 PM
    Is there a reason why ReadWriteProperty interface does not extend ReadOnlyProperty?
    e
    v
    • 3
    • 23
  • j

    José Vicente Cruz

    10/26/2020, 5:10 PM
    Hello guys. First of all, let me introduce myself. My name is José DA CRUZ, I am Brazilian, working for Amadeus in the south of France since 2008 and I am glad to be here talking to you today. I am currently leading a reengineering program inside my organisation and I felt in love with Kotlin. 🙂 Since I did not manage to promote Kotlin (yet) as a replacement for Java in my group, I would like to start contributing to the overall Kotlin’s ecosystem. I googled about contributing to Kotlin on Youtube and I found this video here:

    https://www.youtube.com/watch?v=-y2vW94mBDE&amp;t▾

    . I did not not find anything more recent than that. If you guys have any other suggestion, please let me know. Cheers, José.
    ✅ 1
    n
    r
    • 3
    • 6
  • a

    ahmad abas

    10/27/2020, 5:26 AM
    been reading on
    jetpack compose
    . It seems like an amazing tools. When will it be production ready, v1.0?
    :google: 3
    l
    • 2
    • 1
  • u

    3bdoelnaggar

    10/27/2020, 11:05 AM
    what is the different between
    @Entity(tableName = "logs")
    data class Log(@PrimaryKey(autoGenerate = true)
                     var id: Long = 0,val msg: String, val timestamp: Long)
    and
    @Entity(tableName = "logs")
    data class Log(val msg: String, val timestamp: Long) {
    
        @PrimaryKey(autoGenerate = true)
        var id: Long = 0
    }
    m
    • 2
    • 2
  • k

    KamilH

    10/27/2020, 1:12 PM
    Is it possible to access classes from
    buildSrc
    module in regular code (not
    build.gradle
    files)? I’ve got some strings declared there that I would like to access in runtime
    v
    t
    j
    • 4
    • 19
  • a

    Animesh Sahu

    10/27/2020, 3:26 PM
    Why are assignments not expression in Kotlin? Is there a limitation, or it is intended to not be an expression?
    n
    v
    +2
    • 5
    • 58
  • b

    Big Chungus

    10/27/2020, 9:30 PM
    Does anyone have an article or example of using proguard with ktor (or any non-android kotlin) app?
    r
    g
    • 3
    • 3
  • j

    Jason5lee

    10/28/2020, 2:02 AM
    Which JDK builds gradle project faster? OpenJDK 15 or GraalVM CE of JDK 11? Or is there a better choice?
    g
    n
    • 3
    • 5
  • j

    J6ey

    10/28/2020, 4:23 AM
    Hi guys what's the most concise way to write this Swift code in Kotlin?
    guard let type = model.type, let value = model.value, value != 5 else {
                return
            }
    v
    g
    • 3
    • 8
  • s

    spierce7

    10/28/2020, 5:20 AM
    Anyone have any thoughts on why the sharp decline in Kotlin searches recently? Interestingly,
    react native
    has a similar trend. I’m just curious what would cause a sudden down-spike like that.
    👀 2
    j
    j
    r
    • 4
    • 5
  • h

    Hexa

    10/28/2020, 7:33 AM
    I saw this tweet but I'm still lost when it is a good idea to catch Throwable as there is not a very clear example provided in the tweet or I got lost reading the conversation https://twitter.com/relizarov/status/1299248297849303040?s=19
    👍🏾 1
    t
    n
    +3
    • 6
    • 9
  • s

    Saul Wiggin

    10/28/2020, 9:43 AM
    Implementing a QR code analyser from firebase. The app crashes after about 30 second with the error OutOfMemoryError: no stack trace available. Is this the memory available on my computer?
    a
    l
    • 3
    • 2
  • m

    Martin Barth

    10/28/2020, 10:14 AM
    what assertion library would you recommend? AssertJ or something Kotlin specific?
    a
    c
    +2
    • 5
    • 4
  • a

    akuleshov7

    10/28/2020, 10:17 AM
    Hey guys, we have created a linter (checker + autofixer) for Kotlin with a huge number of rules. Will be great if you will support it at least with a very simple thing: star on a GitHub: https://github.com/cqfn/diKTat But if you will have a chance try it in your CI/CD :) We are already added to awesome-kotlin and awesome-static-analysis, but still need some support from you!
    a
    • 2
    • 70
  • m

    Marc Reichelt

    10/28/2020, 3:23 PM
    Hey there! I’m working on an article about Kotlin, and I’m looking for a good resource that shows its recent growth, maybe even compared to other languages like Java. What are good resources out there that are independent from JetBrains (which is arguably biased ;))?
    j
    k
    e
    • 4
    • 6
  • t

    thanksforallthefish

    10/29/2020, 9:17 AM
    is it somehow possible to define the copy method generated by a data class in an interface? I am trying to figure out a way of refactoring some code that makes extensive use of
    copy
    and
    equals
    and being able to have an interface would help me doing the refactor incrementally. eg:
    interface Test {
      val field: String
      fun copy(field: String)
    }
    
    data class TestData(override val field: String) : Test
    but ofc this does not compile. I don’t think it is really doable, but hope is the last to die they say 🙂
    k
    v
    +2
    • 5
    • 14
  • m

    Marshall

    10/29/2020, 2:37 PM
    Is this the best way to provide read only access to a mutable list:
    class C {
        private val _elementList = mutableListOf<Element>()
    
        val elementList: List<Element>
             get() = _elementList
    }
    Taken from https://kotlinlang.org/docs/reference/coding-conventions.html#property-names
    🎉 1
    b
    v
    +2
    • 5
    • 46
  • m

    Martin Barth

    10/29/2020, 2:52 PM
    is there a nicer way to write this:
    fun convertMaybe(record: Record?): DataObject? {
            return if (record != null) converter.buildDataObject(record) else null
        }
    n
    r
    n
    • 4
    • 16
  • u

    ursus

    10/29/2020, 9:37 PM
    Can I create a nested class on a class I dont have access to? Something like
    enum class Parent.Child {
        BAR, QUAX
    }
    where Parent is generated, so I cannot put the Child there directly
    b
    l
    • 3
    • 3
  • d

    Daniel

    10/29/2020, 10:40 PM
    How do multiple collectors of the same flow behave? I haven't been able to find anything in the docs about it. When I try it, each new emission is sent to one of the collectors
    b
    • 2
    • 1
  • u

    user

    10/30/2020, 9:13 AM
    kotlinx.coroutines 1.4.0: Introducing StateFlow and SharedFlow Today we’re pleased to announce the release of version 1.4.0 of the Kotlin Coroutines library. The highlights of the release are StateFlow and SharedFlow, which are being promoted to stable API. StateFlow and SharedFlow are designed to be used in cases where state management is required in an asynchronous execution context with Kotlin Coroutines. The […]
    b
    a
    • 2
    • 2
  • j

    Jukka Siivonen

    10/30/2020, 12:57 PM
    Sorry, didn't find better place to ask so is anyone familiar with hibernate-validator causing problem javax.validation.ConstraintDeclarationException: HV000131: A method return value must not be marked for cascaded validation more than once in a class hierarchy, but the following two methods are marked as such when Kotlin delegate interface is used? I tried to look decompiled source but I'm still not sure what is causing this
    • 1
    • 4
  • m

    mbonnin

    10/30/2020, 1:56 PM
    Can I assume a
    mutableMapOf()
    to preserve iteration order on key re-insertion like a LinkedHashMap ?
    r
    s
    +2
    • 5
    • 39
  • p

    platypusguy

    10/31/2020, 3:05 AM
    Is there any progress on determining whether unsigned ints are going to remain in the language. They were beta in 1.3 and I was hoping they'd be fully baked in 1.4, but I didn't see anything about them either way in the 1.4 docs. Does anyone know?
    s
    • 2
    • 3
  • a

    Afzal Najam

    10/31/2020, 3:09 AM
    might sound like a completely silly question but would there be some value in having an
    always
    in a when block? Like
    when (something) {
      FIRST_CASE -> doThis()
      SECOND_CASE -> doThat()
      else -> doSomethingElse()
      always -> andAlwaysDoThis()
    }
    I mean, sure, we can just write the always part outside of the when block but not when it's an expression body. Just wondering.
    a
    c
    • 3
    • 4
  • a

    Ananiya

    10/31/2020, 9:03 AM
    hello there, i have made discord bot with kotlin and dialogflow , but i am comfused in how to deploy that project in heruku since it is kotlin dsl build script project in ? or i there any better alternative to heruku?
    a
    v
    • 3
    • 12
  • b

    bod

    10/31/2020, 3:37 PM
    Hello, World! I just stumbled upon something that surprised me: when using delegation to another property (new in 1.4, see https://kotlinlang.org/docs/reference/delegated-properties.html#delegating-to-another-property), it looks like the
    get
    of the delegated property is called at init time. So in a sense, these 2 constructs don't do the same:
    // old way: wrapped.a is called only when this.a is called
    val a: Boolean get() = wrapped.a
    
    // new way: wrapped.a is called when this.a is called but also right here at init
    val a by wrapped::a
    Is this correct / intended or am I missing something?
    😐 1
    a
    • 2
    • 1
Powered by Linen
Title
b

bod

10/31/2020, 3:37 PM
Hello, World! I just stumbled upon something that surprised me: when using delegation to another property (new in 1.4, see https://kotlinlang.org/docs/reference/delegated-properties.html#delegating-to-another-property), it looks like the
get
of the delegated property is called at init time. So in a sense, these 2 constructs don't do the same:
// old way: wrapped.a is called only when this.a is called
val a: Boolean get() = wrapped.a

// new way: wrapped.a is called when this.a is called but also right here at init
val a by wrapped::a
Is this correct / intended or am I missing something?
😐 1
a

Animesh Sahu

10/31/2020, 4:36 PM
Seems interesting, both would do the same. get is simply a getter method (is invoked everytime property is accessed). And the second style may have a performance penalty as using reflections...
View count: 2