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
getting-started
  • v

    v79

    08/20/2021, 10:15 AM
    Is there a rivalry between Kotlin and Rust developers? I posted a tweet hinting that I was going to quit Kotlin, and Rust devs started liking and retweeting it...
    r
    a
    +5
    • 8
    • 9
  • r

    Richard Gomez

    08/20/2021, 7:01 PM
    Is it possible to create 'helper functions' to instantiate annotations from 3rd-party libraries? I'm using SpringDoc to define OpenAPI metadata, and would like to remove visual clutter. e.g., something like this; this doesn't work because `Annotation class cannot be instantiated`:
    fun apiResponseOf(code: Int, kclass: KClass<*>) = ApiResponse(responseCode = code.toString(), content = arrayOf(Content(schema = Schema(kclass))))
    
    @Operation(summary = "List all Foos")
    @ApiResponses(
        apiResponseOf(200, FooResponse::class)
    )
    Instead of:
    @Operation(summary = "List all Foos")
    @ApiResponses(
        ApiResponse(responseCode = "200", content = [Content(schema = Schema(implementation = FooResponse::class))])
    )
    y
    • 2
    • 2
  • s

    Siva Nimmala

    08/20/2021, 8:58 PM
    Hi, I'm using Jetpack Compose for desktop application. How to choose folder (folder pick) ? please help me with a snippet of code
    a
    • 2
    • 1
  • n

    nilTheDev

    08/21/2021, 3:48 PM
    It has been sometime since I started learning
    Kotlin
    . I feel
    gradle
    is indispensable for any
    kotlin
    project. Be it in
    Android
    or some other frameworks. But it is still a magic for me. How does it pull stuff from the repositories, how does it build projects and so on. Any suggestion on where I can learn about it from the bottom-up? Only some basics stuff that we use day-to-day would be fine. It doesn't feel comfortable to use some tool that I don't understand.
    h
    v
    • 3
    • 4
  • m

    MisileLab

    08/22/2021, 3:08 AM
    How to play mp3 in kotlin? (not android)
    y
    • 2
    • 1
  • ł

    Łukasz Bednarczyk

    08/22/2021, 7:05 PM
    How can I inject (in the Koin) mocked objects in a Ktor app in tests?
    d
    n
    • 3
    • 6
  • a

    Anil Kumar

    08/23/2021, 5:21 PM
    Is there a way to interop Python <--> Kotlin
    h
    c
    +2
    • 5
    • 8
  • p

    Pablo Schmid

    08/23/2021, 11:00 PM
    Hi, I'm using jacoco for test coverage and I'm seeing that inline functions with reified types are part of the missed instructions and missed branches in the coverage report. Does somebody know how to overcome this problem? Is it possible? Thanks in advance,
    • 1
    • 1
  • j

    James Whitehead

    08/24/2021, 11:36 AM
    Hi all, sorry if this isn't the place for this, I tried in #reflect but didn't get any responses 😞 A couple of questions with respect to reflection: 1. Is there an equivalent in Kotlin Reflect to Java's 
    isInterface
     ? I see we have 
    isAbstract
     , 
    isOpen
     , etc, but I haven't found anything for interface. 2. Follow up question; is 
    MyClass::class.java.interfaces
     the recommended way to get the interfaces implemented by a given class?
    i
    r
    • 3
    • 7
  • a

    Alexander Suraphel

    08/24/2021, 4:34 PM
    What is the difference between
    *val* x: String? = y *as* String?
    and
    *val* x: String? = y *as*? String
    ?
    r
    c
    • 3
    • 5
  • x

    xii

    08/24/2021, 7:32 PM
    question: how would you do something specific only on last index while doing a collection.map{ }?
    p
    c
    • 3
    • 3
  • x

    xii

    08/24/2021, 7:34 PM
    and also, i've upgraded for kotlin 1.3 to 1.4 and noticed some smart casts to string have broken; is doing toString in the original object sufficient, or does smart cast do something I'm not taking into account?
    c
    k
    • 3
    • 14
  • a

    althaf

    08/26/2021, 7:34 AM
    val s: Array<LongArray> = Array(5) { LongArray(10) }
    println("size" + s[0].size)
    is this the only way to get col size ^^
    k
    s
    n
    • 4
    • 7
  • j

    Justin Tullgren

    08/26/2021, 1:45 PM
    Hi, is it possible to have a lambda with receiver for
    fun interface
    types when creating them using the lambda syntax? I can't seem to make it work without actually making a concrete class.
    y
    • 2
    • 4
  • j

    jean

    08/26/2021, 2:11 PM
    I have this data class
    @Serializable
    data class ApiResponse<T> (
    
        @Serializable(with = HttpStatusCodeSerializer::class)
        val code: HttpStatusCode,
    
        val errors: List<KlubberError> = emptyList(),
        val data: T,
    )
    Does it make sense to use a type
    ApiResponse<Nothing>
    in case of errors? And what should I pass for the
    data
    parameter?
    val response = ApiResponse<Nothing> (
        code = myCode,
        errors = listOf(error1, error2),
        data = <what should I use here?>,
    )
    Using Unit instead of Nothing allows me to write
    data = Unit
    is that a better approach?
    p
    ł
    • 3
    • 4
  • a

    Alex

    08/26/2021, 2:32 PM
    Does anyone know if Exposed supports Kotlin’s value (inline) classes?
    h
    • 2
    • 2
  • m

    MisileLab

    08/26/2021, 3:55 PM
    What is this error mean?
    Unresolved reference: implementation
    My build.gradle.kts file https://pastebin.com/EAcCPBff
    r
    n
    • 3
    • 6
  • k

    Kirill Grouchnikov

    08/26/2021, 7:39 PM
    How do I convert a
    ByteArray
    to
    byte[]
    so that I can pass it to a Java method that accepts the "traditional" byte arrays?
    n
    e
    • 3
    • 3
  • n

    nkiesel

    08/26/2021, 8:35 PM
    I get an "ERROR Overload resolution ambiguity" for
    (1..10).sumOf { if (it % 2 == 0) 1 else 0 }
    . This looks like a bug to me (I tried both 1.5.21 and 1.5.30). I can avoid that using e.g.
    (1..10).sumOf { if (it % 2 == 0) 1L else 0L }
    or
    (1..10).sumOf { if (it % 2 == 0) 1.toInt() else 0.toInt() }
    , but the first one produces a
    Long
    instead of an
    Int
    and the 2nd one is just ugly.
    e
    • 2
    • 4
  • p

    Patrick Ramsey

    08/27/2021, 4:41 AM
    Hmm… not sure where to post this since #general is now #announcements But does anyone know if there’s a way for a data class to inherit its toString() implementation from another class? (ie, is there a way to not get the automatically generated data class toString() implementation)
    e
    y
    • 3
    • 3
  • j

    Jason5lee

    08/27/2021, 6:33 AM
    I’d like to define some types or functions in
    a.b.c.d
    and in another place I can
    import a.b.c.d
    and reference them as `d.TypeName`/`d.function`. Is there a better way other than defining the inner
    d
    as an object and put everything inside, which I’m not sure whether it is a good practice.
    s
    • 2
    • 1
  • j

    jeggy

    08/27/2021, 8:57 AM
    When using the Kotlin Debugger it happens over and over again that my variables are marked as
    'this@with' is not captured
    . Is there anything I can disable to not optimise the Kotlin Compiler when running in debug mode?
    t
    a
    • 3
    • 3
  • m

    mcpiroman

    08/27/2021, 1:05 PM
    How do I define a sequence that enumerates all ancestors of a node in a tree (nodes have multiple parents)? Code in 🧵
    d
    • 2
    • 4
  • m

    MisileLab

    08/27/2021, 1:49 PM
    How can i play audio in korge using korau?
    t
    • 2
    • 2
  • j

    Jonathan Mew

    08/27/2021, 2:48 PM
    Couple of
    value class
    queries 🧵
    s
    • 2
    • 7
  • c

    Chris Fillmore

    08/27/2021, 3:44 PM
    Is anyone using any Kotlin state machine libraries? any recommendations?
    f
    c
    m
    • 4
    • 7
  • r

    Richard Gomez

    08/27/2021, 3:54 PM
    Perhaps I'm misremembering, but isn't it possible to override a getter with a val? Given the following Java interface, I'd thought I'd be able to satisfy it with `data class MyOAuth2User(override val name: String) : OAuth2User`; however, it complains that
    'name' overrides nothing
    .
    // OAuth2User.java
    public interface OAuth2User {
        String getName();
    }
    ✅ 1
    h
    • 2
    • 3
  • p

    Pablo Schmid

    08/27/2021, 9:11 PM
    Hi, does anyone know if sealed interfaces are experimental in 1.5.3? Thanks.
    p
    • 2
    • 2
  • d

    Dmitry

    08/28/2021, 4:45 AM
    Please, I need your help. I have a great desire to create my own Kotlin library or utility. Do you have any ideas?
    k
    • 2
    • 7
  • e

    elect

    08/28/2021, 9:15 AM
    extending the following interface
    public interface Named {
        String getName();
    is there a way to overwrite that in an extending class using a plain field (
    var name: String
    ) instead of using mandatory a method?
    e
    • 2
    • 2
Powered by Linen
Title
e

elect

08/28/2021, 9:15 AM
extending the following interface
public interface Named {
    String getName();
is there a way to overwrite that in an extending class using a plain field (
var name: String
) instead of using mandatory a method?
e

ephemient

08/28/2021, 10:13 AM
https://youtrack.jetbrains.com/issue/KT-6653
e

elect

08/28/2021, 4:20 PM
damn, I even voted for it... I totally forgot 😄 thanks
View count: 10