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

    jdemeulenaere

    07/08/2019, 1:27 PM
    Hey guys! I built a DSL in Kotlin and I would like people to easily play with that DSL. I think that the best would be to have a very simple online editor with just syntax highlighting and code completion. I will need to customize code completion a little bit to make sure it only suggests classes and methods from my DSL package (the users won't need access to the whole Kotlin stdlib). If you have any suggestion for an existing editor that I could use, I am interested 🙂
    p
    i
    • 3
    • 4
  • n

    Nicholas Bilyk

    07/08/2019, 3:03 PM
    Hi Gradle experts. I'm pretty new to Gradle, and I'm having trouble figuring out how to get a Kotlin multi-platform multi-project build set up as a composite dependency. I'm using includeBuild to pull in the mpp utility project
    includeBuild("../acornui") {
    	dependencySubstitution {
    		substitute(module("com.acornui:acornui-utils-metadata")).with(project(":acornui-utils"))
    		substitute(module("com.acornui:acornui-utils-jvm")).with(project(":acornui-utils"))
    		substitute(module("com.acornui:acornui-utils-js")).with(project(":acornui-utils"))
            }
    }
    This actually works as far as building is concerned, but the IDE doesn't accept the substitution. Any suggestions for where I can go from here?
    d
    a
    • 3
    • 4
  • n

    Nir

    07/08/2019, 3:12 PM
    A question about
    object
    and companion objects, philosophically
    r
    s
    +2
    • 5
    • 18
  • f

    Florian

    07/08/2019, 6:04 PM
    what is the difference between an operator and infix function
    p
    k
    • 3
    • 3
  • m

    mp

    07/08/2019, 6:11 PM
    Let's not get wrapped up in the threadlocal. How about this. I have a consuemr
    (T) -> Unit
    and a producer
    () -> T
    . I want to store pairs of those, but with a different
    T
    for each pair.
    d
    • 2
    • 6
  • c

    camdenorrb

    07/08/2019, 8:05 PM
    I broke Kotlin
    a
    k
    • 3
    • 7
  • c

    camdenorrb

    07/08/2019, 8:26 PM
    n
    a
    +3
    • 6
    • 200
  • t

    Tuan Kiet

    07/09/2019, 1:21 AM
    @Target(
        AnnotationTarget.FIELD,
        AnnotationTarget.FUNCTION,
        AnnotationTarget.PROPERTY_GETTER,
        AnnotationTarget.PROPERTY_SETTER
    )
    annotation class FieldName(
        val value: String
    )
    
    data class UserEntity(
        @FieldName("userName") val userName: String
    )
    somehow
    UserEntity::userName.annotations
    return an empty list. What did I do wrong?
    c
    • 2
    • 7
  • v

    ValV

    07/09/2019, 8:08 AM
    I have faced some weird thing from Java - method reference operator on an object like so:
    RegexCompleter("SomeCoolRegexString", myHashMap::get)
    . I've read from 😒tackoverflow: that Kotlin does not support method reference on objects. How to convert to Kotlin?
    i
    i
    • 3
    • 9
  • m

    Mohamed Ibrahim

    07/09/2019, 1:05 PM
    is it possible to create new keyword like in Kotlin for example I have a dyanmic string and want to map it to one of possible values .. so I think
    when
    is the right choice .. what I need to achieve something like this
    when ( lang ) {
    equalIgnoreCase "AR" -> "Arabic"
    equalIgnoreCase "EN" -> "English"
    equalIgnoreCase "RU" -> "Russian"
    }
    m
    w
    +2
    • 5
    • 6
  • t

    thana

    07/09/2019, 1:51 PM
    why can a
    val
    from an interface be overwritten as
    var
    in the implementation?
    b
    m
    +3
    • 6
    • 27
  • n

    Nir

    07/09/2019, 2:32 PM
    Does anyone know why klock backs its datetimes with double instead of integer? This is... Very odd. Is klock the standard for datetime stuff in kotlin?
    d
    p
    +3
    • 6
    • 51
  • r

    robstoll

    07/09/2019, 5:23 PM
    I am not yet familiar with contracts. Is it possible to pass contracts further up the call chain; kind of generic contracts? E.g.
    fun <R> foo(f : ()-> R) = f ()
    specify that foo takes over the contract of
    f
    a
    • 2
    • 1
  • s

    StevieB

    07/09/2019, 6:44 PM
    I have a question for the assembled wisdom here (probably in the wrong channel, please correct me). I have been playing around with kotlin, jlink, javafx, tornadofx and JDK 11 and I am pleasantly surprised how well its working (at the basic level anyway). BUT when I try to use a recent kotlin release (1.3.41) I have a problem which seems odd, somewhere in the jlinking process it generates a big module-info.java file which attempts to export kotlin.native.concurrent, it balks at this, apparently because native is a java reserved word!! That package isn't in 1.3.10 which works. Does anyone have any advice on how to surmount this problem? I've tried to find a way of excluding it, but I haven't found that and anyway I don't think that's the correct thing to do.
    i
    h
    • 3
    • 5
  • n

    nfrankel

    07/09/2019, 8:20 PM
    hi dears kotliners my issue of the day: how can i have a higher-order function that takes a vararg? something like:
    fun foo( (vararg args: Any?) -> Unit) = ...
    s
    n
    t
    • 4
    • 15
  • n

    Nir

    07/09/2019, 8:42 PM
    (I was also interested/surprised to see that variadic generics were not on the "top 20 wanted" list for Kotlin)
    k
    n
    • 3
    • 23
  • j

    jw

    07/09/2019, 9:09 PM
    https://github.com/Kotlin/KEEP/pull/191
    😟 1
    k
    n
    r
    • 4
    • 27
  • h

    Hullaballoonatic

    07/10/2019, 3:16 AM
    Why shouldn't we be able to set the visibility of interface fields and methods? It would be nice for things like this:
    interface Foo {
        var recentBar: Int
    
        protected val onBar: (Int) -> Int
    
        fun bar(x: Int): Int {
            recentBar = onBar(x)
            return recentBar
        }
    }
    I don't intend this as a suggestion, per say, hence why posting here. I assume there's an important (paradigmatic?) reason I'm missing for why such a suggestion is a terrible idea.
    d
    j
    +3
    • 6
    • 17
  • e

    Evgeniy Zaharov

    07/10/2019, 7:11 AM
    Hi. I have a problem with deserialising
    data class
    contains params with
    inline
    classes. For deserialisation I use
    jackson
    and it fail with it. But then I try to discover a problem I found that this
    data class
    compile to class with private main constructor. Is it expected behaviour or bug (for me at lease, and feature for others)? It seems not right solutions for it, because for initialisation of
    Outer
    class kotlin compile use synthetic method with
    DefaultConstructorMarker
    witch doesn’t contains any additional check for inline params and only calls private constructor after. Why just not make main constructor
    public
    and use it for initialisation? Simple example for reproduce is below:
    inline class InlineValue(val value: String)
    
    data class Outer(
        val value: Int,
        val inlineValue: InlineValue
    )
    and in will be compiled to:
    public final class Outer {
       ...
       private Outer(int value, String inlineValue) {
          this.value = value;
          this.inlineValue = inlineValue;
       }
        ...
    }
    d
    • 2
    • 5
  • y

    yayabobi

    07/10/2019, 12:57 PM
    hey everyone. thought you’d like to know that the free Codota plugin (AI based code completions) for IntelliJ, Android Studio, and Eclipse is now supporting Kotlin too. It’s totally free and would love to hear the feedback of the Kotlin community on the suggestion Codota provides for Kotlin. Installation instructions: codota.com/lp-1
    👍 7
    a
    f
    p
    • 4
    • 3
  • a

    Andrew Gazelka

    07/10/2019, 1:07 PM
    can someone explain this auto type? (when doing
    flowOf(1, 1.0, 2, 2.0)
    )… don’t understand the
    &
    e
    m
    +3
    • 6
    • 15
  • t

    thiagoretondar

    07/10/2019, 2:23 PM
    Is it a good practice?
    data class Property(
        val name: String,
        val value: String
    )
    
    data class Element(
        val name: String,
        val properties: List<Property>?,
        val elements: List<Element>?  ---> REFERENCE ITSELF
    )
    d
    r
    h
    • 4
    • 12
  • r

    Ruckus

    07/10/2019, 2:28 PM
    Quick style question. Say you're given
    a: List<A>
    and want an equal amount of `B`s (that don't depend on
    A
    . Do you prefer: 1️⃣
    a.map{ B() }
    2️⃣
    List(a.size) { B() }
    2️⃣ 10
    p
    k
    +3
    • 6
    • 11
  • n

    Nir

    07/10/2019, 2:33 PM
    Question: I know this would not be possible with "regular" Java generics, but I thought maybe it is somehow possible with Kotlin reified generics. Basically, would like to be able to do something like:
    inline fun <reified T> foo() : Int {
        return T.bar
    }
    Basically, a way to access values, functions, etc, from the type itself, instead of from an instance of that type.
    k
    d
    +4
    • 7
    • 87
  • k

    kartikpatodi

    07/10/2019, 4:33 PM
    Is there a way that a function is called and then not return to call site? I have a exit function which does the cleanup and logging.
    d
    k
    +2
    • 5
    • 16
  • r

    redrield

    07/10/2019, 8:32 PM
    Is there a way for a compiler plugin to see the instruction that occurs directly after the one it's currently visiting?
    p
    • 2
    • 1
  • a

    Andrew Gazelka

    07/11/2019, 2:55 AM
    is there any point in having `Channel`s when you can just have hot flows?
    g
    • 2
    • 2
  • a

    Andrew Gazelka

    07/11/2019, 4:38 AM
    or what does it do in contrast to
    .copy(...)
    q
    p
    • 3
    • 7
  • v

    ValV

    07/11/2019, 5:50 AM
    What is the Kotlin's way to work with
    <http://System.in|System.in>
    ,
    System.out
    ?
    b
    • 2
    • 6
  • v

    ValV

    07/11/2019, 8:05 AM
    How to do a list of consumers? Via
    typealias
    ?
    typealias Consumer<T> = (T) -> Unit
    callbacks = listOf<Consumer<MyType>>()
    k
    • 2
    • 2
Powered by Linen
Title
v

ValV

07/11/2019, 8:05 AM
How to do a list of consumers? Via
typealias
?
typealias Consumer<T> = (T) -> Unit
callbacks = listOf<Consumer<MyType>>()
k

karelpeeters

07/11/2019, 8:08 AM
Yeah or just inline that type,
listOf<(MyType) -> Unit>()
v

ValV

07/11/2019, 8:11 AM
😲 interesting. I'd better inline, thanks for the hint
View count: 2