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

    jmfayard

    06/14/2017, 11:01 AM
    Hello, I have the
    KotlinCompileDaemon
    which sometimes take 300% of the CPU or throws with a
    GC overhead limit exceeded
    . What kind of infos can I provide / tools I can use to open a useful bug report on kotl.in/issue?
    i
    3 replies · 2 participants
  • j

    janvladimirmostert

    06/14/2017, 11:39 AM
    I’m curious, what was the design decision that made
    1..4
    return you a list, but
    4..1
    doesn’t return anything. One would expect
    4..1
    equals
    (1..4).reversed()
    .
    👍 3
    d
    h
    +1
    31 replies · 4 participants
  • p

    Paul Woitaschek

    06/14/2017, 12:41 PM
    I have about 20 annotations that need to be exactly like that but I want to avoid code duplication
    😱 2
    l
    k
    +1
    10 replies · 4 participants
  • m

    mg6maciej

    06/14/2017, 6:13 PM
    No shortcuts in K. Code does not have to be concise, it has to be readable in the long run for the team maintaining it.
    👆🏽 3
    :kotlin-flag: 1
    g
    1 reply · 2 participants
  • m

    mg6maciej

    06/14/2017, 6:31 PM
    If you are using readonly in this case, then I would probably go with
    someSet = someSet.withOrWithout(someFlag, someElement)
    .
    1 reply · 1 participant
  • s

    scott

    06/14/2017, 6:48 PM
    i mean if you really want to you could use the strategy pattern, which is often used for dealing with repetitive conditionals , https://sourcemaking.com/design_patterns/strategy
    👍 1
    r
    1 reply · 2 participants
  • c

    codeslubber

    06/14/2017, 6:50 PM
    better example would be something like BMIComputer, where there are different ways to compute a value.. the ground transport is not really a strategy it’s a type problem…
    r
    4 replies · 2 participants
  • r

    raulraja

    06/14/2017, 8:58 PM
    What is a good channel to ask about potential odd behaviors/bugs derived from using
    reified
    type args?
    r
    2 replies · 2 participants
  • s

    Slackbot

    06/14/2017, 9:18 PM
    This message was deleted.
    p
    1 reply · 2 participants
  • m

    miha-x64

    06/15/2017, 11:22 AM
    https://github.com/adelnizamutdinov/kotlin-either
    r
    4 replies · 2 participants
  • d

    dalexander

    06/15/2017, 12:10 PM
    Should
    val b: Byte = 3
    when(b) { 1 -> {} }
    compile? It currently fails with the message “Incompatible types, Int and Byte” because it treats 1 as an int literal, and there’s no way to specify byte literals. Asking here before I file a ticket (it also fails for Shorts).
    r
    1 reply · 2 participants
  • b

    borisdamato

    06/15/2017, 2:27 PM
    Is it just me or code completion on kotlin seems slower? (AS3.0 C3)
    😥 1
    b
    s
    +2
    9 replies · 5 participants
  • a

    arocnies

    06/15/2017, 6:19 PM
    Thanks. For some reason I felt like it may be possible for some reason. Which is confusing because at the same time it doesn't make sense. I was hoping to use it for statements like
    "foo" = bar()
    l
    1 reply · 2 participants
  • a

    arocnies

    06/15/2017, 6:36 PM
    It's overloading the invoke( () -> { }) operator with a trailing clojure.... Which may be confusing in itself so opinions are welcome
    r
    11 replies · 2 participants
  • r

    Ruckus

    06/15/2017, 8:20 PM
    If you're going to be doing that kind of stuff, you may just want to not use an argument:
    val name = item.name
    when {
        name == "john" -> { ... }
        name.startsWith("Mary") -> { ... }
        name.contains("Fred") -> { ... }
    }
    👍 3
    j
    1 reply · 2 participants
  • s

    supaham

    06/16/2017, 2:54 AM
    If I have
    class Bar
    class Baz: Bar
    class Foo<T: Bar>() {
      fun input(t: T)
      fun returnT(): T
    }
    Then
    class Other(val foo: Foo<Bar>)
    class Impl(foo: Foo<Baz>): Other(foo)
    Impl generates:
    [TYPE_MISMATCH] Type mismatch: inferred type is Foo<Baz> but Foo<Bar> was expected
    How can I overcome this issue?
    g
    1 reply · 2 participants
  • j

    janvladimirmostert

    06/16/2017, 10:30 AM
    I’ve not used Kotln Delegation before since I don’t fully comprehend what it’s useful for. Is it correct to state that delegation allows you to delegate execution in the same way that a proxy can delegate execution to 1 or more implementations of a class ?
    ✅ 1
    s
    2 replies · 2 participants
  • f

    fmd

    06/16/2017, 11:26 AM
    Are there some kind of JVM annotations for this purpose, or is explicit type selection not supported?
    1 reply · 1 participant
  • v

    vaskir

    06/16/2017, 12:38 PM
    is it a known issue?
    d
    1 reply · 2 participants
  • w

    witoldsz

    06/16/2017, 9:07 PM
    Hi guys! What do you think about languages with tagged unions aka sum types? Did you managed to use such a language? Kotlin has something that reminds me them: sealed classes, but they look very verbose and I am not sure if they are useful as tagged unions… (I have to check this, my Kotlin experience is too short)
    s
    r
    +4
    33 replies · 7 participants
  • j

    janvladimirmostert

    06/16/2017, 11:19 PM
    shouldn’t those classes be
    open class
    for spring annotations to work ?
    u
    1 reply · 2 participants
  • x

    x80486

    06/16/2017, 11:35 PM
    If I use the Kotlin annotations, it doesn't work...if not, everything is OK...
    r
    j
    7 replies · 3 participants
  • j

    janvladimirmostert

    06/17/2017, 12:19 AM
    I’ve tried Spring Boot on one project, managed to quickly build something with it, then came in some requirements which Spring Boot simply couldn’t do in a nice way and I was stuck. Getting SSL-offloading to working on a Spring Boot project simply didn’t seem possible at the time. Eventually ditched Spring Boot and made the switch to VertX
    x
    15 replies · 2 participants
  • d

    darkmoon_uk

    06/17/2017, 7:47 AM
    Why does
    Array
    have an inline constructor; when the compiler says this is disallowed in my own code?
    v
    r
    22 replies · 3 participants
  • e

    evanchooly

    06/17/2017, 11:27 PM
    i've thought about bootstrapping a new ASL-licensed one since pircbotx is GPL'd and jibbler has basically vanished so can't be persuaded to relicense pircbot itself.
    o
    5 replies · 2 participants
  • a

    akbarsha03

    06/18/2017, 7:05 PM
    There is no difference between
    check
    and
    require
    in kotlin
    Preconditions.kt
    😕
    d
    3 replies · 2 participants
  • w

    witoldsz

    06/18/2017, 10:28 PM
    Looks like there is no simple solution, you say
    !!
    is ugly and can make bad, for me the hidden assumptions make my new and shiny Kotlin app throw NPE… (and I was supposed to see NPE ever again). Maybe
    T!
    types should have yet another dot-like operator, so it would be special and everyone could tell "aha, this is Java, nulls allowed".
    a
    2 replies · 2 participants
  • f

    ftomassetti

    06/19/2017, 7:49 AM
    Hi, I just published this guide to all the resources I could find for someone learning Kotlin: https://superkotlin.com/resources-learn-kotlin/ It is part of a new website I have launched to help promoting our favorite language. I was hoping you could help me get the voice out
    👍 5
    w
    2 replies · 2 participants
  • k

    karelpeeters

    06/19/2017, 1:15 PM
    Hey guys, I'm trying out LWJGL and I came accross this piece of code: (https://github.com/Zi0P4tch0/LWJGL-Kotlin-Example/blob/ed8e30bcb0ad5f99a01a4f501461457a0bd9d36f/src/main/kotlin/com/example/Engine.kt#L47). I don't really understand why there's a "kotlin." in front of every type, why is that necessary? It doesn't compile without it, I get the error "Object must be declared abstract or implement abstract base class member public abstract operator fun invoke(p0: Long, p1: Int, p2: Int, p3: Int, p4: Int): Unit defined in org.lwjgl.glfw.GLFWKeyCallback". The definition of the "invoke" method can be found here: (https://github.com/LWJGL/lwjgl3-generated/blob/894ed035ec3037975a344cf719936159a632967b/java/org/lwjgl/glfw/GLFWKeyCallbackI.java#L41)
    d
    6 replies · 2 participants
  • d

    david.bilik

    06/19/2017, 1:55 PM
    hello, why custom setters for private properties are not called inside lambdas? For public property its ok but for private property its set directly without setter (checked via decompiling bytecode to java) .. relevant code
    private var cartProducts: List<CartProduct> = listOf()
       set(value) {
           field = value
           // show value in UI
        }
        
    init {
    	   productsRepository.observeProducts()
                    .subscribe({
                        cartProducts = it.map { CartProduct(it, Random().nextInt(10) + 1) }
                    }, { it.printStackTrace() })
    }
    the setter for cartProducts is not called
    r
    1 reply · 2 participants
Powered by Linen
Title
d

david.bilik

06/19/2017, 1:55 PM
hello, why custom setters for private properties are not called inside lambdas? For public property its ok but for private property its set directly without setter (checked via decompiling bytecode to java) .. relevant code
private var cartProducts: List<CartProduct> = listOf()
   set(value) {
       field = value
       // show value in UI
    }
    
init {
	   productsRepository.observeProducts()
                .subscribe({
                    cartProducts = it.map { CartProduct(it, Random().nextInt(10) + 1) }
                }, { it.printStackTrace() })
}
the setter for cartProducts is not called
r

radityagumay

06/19/2017, 2:49 PM
david.bilik: what are doing here. Make a observer call in init.
View count: 2