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

    Dico

    01/24/2019, 3:48 AM
    When you declare lots of extension functions instead of class members, you end up with very many imports. And extension functions are very common in stdlib,
    kotlin.cinterops
    for kotlin native,
    kotlinx.coroutines
    , and most other projects that use a similar style in this respect. I wonder if people would support the idea that importing a type should also import extension functions of that type that reside in the same file or package. This would mean that if you import
    CoroutineScope
    , you don't need to import
    launch
    or any other builders other than
    runBlocking
    . What do you think?
    g
    g
    e
    • 4
    • 7
  • e

    egorand

    01/24/2019, 5:49 AM
    I’m preparing an internal workshop entirely based on Kotlin Koans and I’m having a really bad experience with the online version - in some cases the Run button just does nothing. The browser console displays the following error:
    Uncaught TypeError: Cannot read property 'execute' of null
        at Object.onRun (main.js:148)
        at main.js:148
        at Object.<anonymous> (main.js:132)
        at p (main.js:132)
        at main.js:132
        at C (main.js:132)
        at O (main.js:132)
        at A (main.js:132)
        at S (main.js:132)
        at L (main.js:132)
    m
    d
    • 3
    • 2
  • a

    ahulyk

    01/24/2019, 9:49 AM
    Hi) Do you know any Mapstruct alternatives what work with Kotlin Data classes?
    p
    g
    • 3
    • 4
  • r

    reik.schatz

    01/24/2019, 10:17 AM
    without package private visibility, what are my options to restrict use of a class to the same package (i.e. spring has a way to map exceptions to http status codes via annotations, I want to make sure that these are only used from the controllers)
    g
    • 2
    • 2
  • d

    Davide Giuseppe Farella

    01/24/2019, 11:25 AM
    Is there some API in stdlib to do that in a cleaner way?
    @Suppress("UNCHECKED_CAST")
    pairsListOfNullableApiParamAndNullableString
            .filterNot { it.first == null || it.second == null }
            .map { it as Pair<ApiParam, String> }
    e
    a
    h
    • 4
    • 6
  • m

    mp

    01/24/2019, 12:04 PM
    hi there Im trying to understand why this
    var externalId: String = ""
    code provide to me this kind of object wrapping. but when I`m trying to set this value in
    data class Id(var externalId: String)
    it actually tooks 16332. And I “miss” my reference I can’t understand why this ref$ObjectRef appears Advice pls some documentation page about this
    t
    a
    • 3
    • 22
  • c

    carlos cdmp

    01/24/2019, 3:10 PM
    Shouldn't this show some unchecked cast warning?
    a
    r
    +2
    • 5
    • 11
  • l

    LeoColman

    01/24/2019, 3:37 PM
    Is there any particular reason for
    Random
    to not have range-based float generation?
    v
    j
    +2
    • 5
    • 8
  • d

    Davide Giuseppe Farella

    01/24/2019, 4:14 PM
    I can’t figure out why this is happening on my class, while is not happening on a
    MutableList
    , for instance 😕
    ✔️ 1
    • 1
    • 3
  • w

    withoutclass

    01/24/2019, 5:34 PM
    Latest Intellij plugin
    1.3.20-release-IJ2018.3-1
    seems to break compiling in Intellij for me. Compiling via command line gradle works. Beginning of error snippet is:
    Error:Kotlin: [Internal Error] java.lang.IllegalStateException: Backend Internal error: Exception during code generation
    Cause: Back-end (JVM) Internal error: wrong code generated
    org.jetbrains.kotlin.codegen.CompilationException Back-end (JVM) Internal error: Couldn't transform method node:Error:Kotlin: [Internal Error] java.lang.IllegalStateException: Backend Internal error: Exception during code generation
    Cause: Back-end (JVM) Internal error: wrong code generated
    org.jetbrains.kotlin.codegen.CompilationException Back-end (JVM) Internal error: Couldn't transform method node:
    create (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;:
    a
    • 2
    • 1
  • t

    tipsy

    01/24/2019, 6:56 PM
    how do people feel about shading the
    stdlib
    dependencies when publishing libraries written in kotlin?
    m
    • 2
    • 2
  • j

    jasondlee

    01/24/2019, 8:35 PM
    i have a data class with a lot of properties. I need to create that class from java code, but I don't want to pass 800 nulls in the ctor. is there a cleaner way around that? @JvmOverloads doesn't seem to like data classes
    s
    • 2
    • 16
  • x

    xenoterracide

    01/24/2019, 8:57 PM
    how can I get the value of a field, when I only know the name of the field (as a string)? I don’t see an example in https://kotlinlang.org/docs/reference/reflection.html
    @ParameterizedTest
        @ValueSource(strings = [ "emr", "packet_100hz", "packet_1hz" ])
        fun channel( channel: String ) {
            assertThat( Channel::class.java ).hasPublicFields( channel.toUpperCase() + "_NEW" )
            assertThat( Channel::`channel`.get() ).isEqualTo( channel + ".new" )
        }
    d
    • 2
    • 1
  • a

    Alper Tekinalp

    01/24/2019, 10:55 PM
    Hi I know that is not directly related with kotlin but does anyone know why
    LocalDate.parse("2000-02-31", DateTimeFormatter.ofPattern("yyyy-MM-dd"))
    parses to
    2000-02-28
    ?
    s
    • 2
    • 4
  • k

    kenkyee

    01/24/2019, 11:11 PM
    Ktlint is broken with 1.3.20 FYI....I had to roll us back because of that...
    s
    p
    • 3
    • 8
  • n

    Nikky

    01/25/2019, 1:17 AM
    i got a JNI error and invalid callstack errors trying to assign string to continuation or so
    g
    • 2
    • 1
  • d

    DefinitelyAHuman

    01/25/2019, 1:29 AM
    is there any code completion for kotlin on atom? coming from golang where i had a full ide in atom.
    d
    • 2
    • 2
  • g

    groostav

    01/25/2019, 9:02 AM
    Hmm. I'm disappointed in kotlinc compiler magic.
    do {
      val x = true
    }
    while(x)
    works but
    do try {
      val x = true
    }
    finally {}
    while(x)
    does not. Can i log this as a bug? Or an enhancement?
    g
    e
    p
    • 4
    • 9
  • c

    coder82

    01/25/2019, 9:47 AM
    is there a way to access the receiver's private members?
    r
    • 2
    • 3
  • m

    Marc Knaup

    01/25/2019, 10:19 AM
    1.3.20 compiler & gradle plugin with 1.3.11 lib dependencies…
    g
    • 2
    • 1
  • r

    robstoll

    01/25/2019, 2:01 PM
    is there a shortcut for
    val a = try { myfun()} } catch(T: Throwable){ null }
    b
    a
    +3
    • 6
    • 10
  • l

    Lamberto Basti

    01/25/2019, 2:21 PM
    Hello 🙂 Is there a guide or some example on how to sign and setup the artifact for mavenCentral in a multiplatform project using Kotlin version 1.3.20 and Kotlin DSL? Following the new guide I was able to avoid artifacts duplications when multi-step-publishing (even tho there is an error in the guide,
    OperatingSystem.current().isLinux
    is the correct way to chech the OS). Now i just need to sign all of them and configure the
    publishing
    extension lambda. The project is this one: https://github.com/lamba92/kotlin-extlib
    d
    • 2
    • 1
  • h

    hyukchan

    01/25/2019, 2:23 PM
    Hi guys, I'm trying to use JPA specification with kotlin, but I'm having compilation errors... Has anyone have good example to show ?
    l
    • 2
    • 5
  • d

    Dalinar

    01/25/2019, 2:51 PM
    I need a good logging library, should I look only in the java world? or is there a good Kotlin logging library?
    :java: 3
    c
    f
    s
    • 4
    • 7
  • a

    alex.hart

    01/25/2019, 2:53 PM
    Timber is pretty great, and I think has a Kotlin variant (pretty sure it supports multiplatform now?)
    d
    j
    +2
    • 5
    • 8
  • t

    tschuchort

    01/25/2019, 7:18 PM
    I have a class hierarchy that represents an AST and I would like to model it with sealed classes to get exhaustion checks in when-expressions. Unfortunately that means I have to put all classes into a single file (which would be several thousand lines long). My idea was to make them all completely abstract (an interface basically) and then move the implementation to Impl classes. The problem with that is that I would no longer be able to inherit implementations (since Kotlin only supports single-inheritance). Is there any more elegant solution than to delegate all the inherited methods manually? Or should I give up on sealed classes completely and use a visitor instead? (I hate visitors but they do have the advantage that client code would still compile when new elements are added to the AST. Although you could achieve the same thing by adding an else-clause to a when-expression despite exhaustion and when-expressions are much more natural to use)
    c
    k
    • 3
    • 17
  • p

    pugnator

    01/25/2019, 7:47 PM
    всем привет как сделать двойное нажатие? есть обработчик или надо писать функцию?
    :stackoverflow: 1
    🏴󠁧󠁢󠁥󠁮󠁧󠁿 1
    g
    • 2
    • 2
  • f

    Foso

    01/25/2019, 7:48 PM
    Do you know of any project that is trying to use Flutter with Kotlin instead of Dart?
    g
    j
    +3
    • 6
    • 20
  • s

    snowe

    01/25/2019, 11:19 PM
    Does anyone have a guide on how to use the
    shadow
    gradle plugin with kotlin? I’m attempting to package kotlinx serialization with my gradle plugin and I can’t figure out the syntax.
    n
    • 2
    • 2
  • d

    Dalinar

    01/26/2019, 7:41 AM
    how do I Kotlinize this ?
    Class.class.getName()
    g
    • 2
    • 1
Powered by Linen
Title
d

Dalinar

01/26/2019, 7:41 AM
how do I Kotlinize this ?
Class.class.getName()
g

gildor

01/26/2019, 9:48 AM
Direct translation would be
Class::class.java.name
View count: 7