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

    Slackbot

    03/23/2019, 9:48 PM
    This message was deleted.
    d
    j
    • 3
    • 2
  • s

    Shan

    03/24/2019, 7:42 AM
    Hey all, have a quick question: if I have a class which has a property whose type will always definitely be a certain type, is there a way I can specify that in my code so I don't have to do exhaustive when checks constantly? I tried using
    as
    but I couldn't get it to work, probably doing it wrong. My use-case:
    Untitled.kt
    c
    s
    +2
    • 5
    • 11
  • s

    Smallville7123

    03/24/2019, 3:14 PM
    how can i optimize this https://bpaste.net/show/a82700459fc2
    l
    • 2
    • 1
  • s

    Slackbot

    03/24/2019, 8:17 PM
    This message was deleted.
    :stackoverflow: 1
    r
    i
    • 3
    • 3
  • s

    Smallville7123

    03/24/2019, 8:23 PM
    Anyone make macro preprocessors?
    g
    • 2
    • 5
  • s

    sitepodmatt

    03/25/2019, 2:16 AM
    val x: () -> Any? = @Repeated(5) {
                "hi"
            }
    
            // test if x has annontation
    //fail       
            println(x::class.java.annotations.first() as Repeated)
    l
    • 2
    • 9
  • j

    jw

    03/25/2019, 2:28 AM
    are source links broken on the API docs again?
    k
    • 2
    • 1
  • d

    David Cuesta

    03/25/2019, 9:26 AM
    Hey guys, Is there any tool/plugin to auto-generate ApiDoc.yaml that integrates with ktor?
    a
    m
    • 3
    • 7
  • t

    thana

    03/25/2019, 10:38 AM
    is there a way, to make a method tailrecursive. when the return is nested in a return?
    k
    d
    t
    • 4
    • 11
  • s

    standinga

    03/25/2019, 1:17 PM
    and would like to have it in the bottom of the file, but this is not possible due to "variable must be initialized" error
    s
    • 2
    • 3
  • s

    standinga

    03/25/2019, 2:16 PM
    I would like to be able to have listener below init
    -.kt
    r
    s
    • 3
    • 7
  • d

    dumptruckman

    03/25/2019, 2:22 PM
    Running into a new problem trying to run some unit tests with Kotlin. I’m making a change to a class in my main code set and when i rerun the test, it is not detecting the changes and is giving me the same error I had before the change. Even adding a println just before that line and now the error points to the printlin. I’m running the tests in IntelliJ. Anyone else run into this?
    r
    a
    +2
    • 5
    • 17
  • r

    rook

    03/25/2019, 4:13 PM
    Is there a way of writing
    infix
    functions that allows the left side to be implied by the context? For example, in
    apply
    🇳🇴 1
    d
    r
    +2
    • 5
    • 5
  • w

    wathek

    03/25/2019, 5:37 PM
    Hi wonderful people, I have been wondering whether there is a difference between using
    as
    and setting the type of a variable, for instance:
    val ids: List<Int> = environment.getArgument('ids')
    VS
    val ids = environment.getArgument('ids') as List<Int>
    j
    s
    p
    • 4
    • 15
  • k

    Kompass

    03/26/2019, 5:38 AM
    @here Hello everybody 😊 I have a small problem with reflection and I will be grateful if someone will suggest possible directions for its solution.
    k
    • 2
    • 1
  • t

    Tsvetozar Bonev

    03/26/2019, 8:22 AM
    Does anyone know if the AppEngine standard environment supports kotlin coroutines?
    g
    s
    • 3
    • 4
  • j

    Jakub Aniola

    03/26/2019, 9:46 AM
    Are coroutines available in Kotlin 1.3 stdlib? When I am looking into coroutines tutorial in documentation (https://kotlinlang.org/docs/tutorials/coroutines/coroutines-basic-jvm.html) it is telling me to add kotlinx to gradle/maven. I am compiling Kotlin in CLI without gradle/maven, so is there possibility to use coroutines in that case?
    g
    s
    • 3
    • 9
  • s

    Stephane M

    03/26/2019, 10:53 AM
    Hello everyone, finally did the Kotlin plunge from Scala and Java, and it's been awesome! Writing a TornadoFX app right now, and it's delightful. Looking forward to learning more
    👋 3
    :kotlin: 6
    t
    • 2
    • 2
  • a

    arekolek

    03/26/2019, 11:23 AM
    Is it possible to use
    @Deprecated
    annotation while having enabled
    allWarningsAsErrors = true
    /
    -Werror
    ? As far as I can tell it’s impossible, but maybe I missed something?
    r
    • 2
    • 7
  • s

    Smallville7123

    03/26/2019, 3:49 PM
    https://github.com/mgood7123/kpp
    h
    • 2
    • 1
  • j

    Jakub Aniola

    03/26/2019, 5:42 PM
    Is there possibility to run Kotlin code in CLI with main inside the class (in companion object or object)? I know, main it would run with main outside the class 😄 As far as I understand that second answer to that question https://discuss.kotlinlang.org/t/is-the-main-function-must-be-a-standalone-function/877 it should work
    asdf.kt
    p
    • 2
    • 3
  • d

    dumptruckman

    03/26/2019, 6:11 PM
    How come IntelliJ doesn’t show deprecated Kotlin methods with a strike through in java code? Am I missing something?
    s
    g
    l
    • 4
    • 11
  • s

    Smallville7123

    03/26/2019, 6:20 PM
    How can I make a method callback whos parameters can be redefined wiithout using a varargs <Any> parameter
    r
    d
    • 3
    • 11
  • j

    jw

    03/26/2019, 7:11 PM
    you could file a bug for the missing inspection. ISE should become check, IAE should be require, null checks for either should be checkNonNull/requireNonNull
    ➕ 5
    h
    • 2
    • 1
  • r

    Ruckus

    03/26/2019, 7:35 PM
    Is there any difference (at runtime) between
    import javafx.scene.paint.Color`
    and
    typealias Color = javafx.scene.paint.Color
    t
    • 2
    • 1
  • r

    Ruckus

    03/26/2019, 7:36 PM
    In the same vein, what about
    import javafx.scene.paint.Color as ColorFX
    and
    typealias ColorFX as javafx.scene.paint.Color
    p
    d
    • 3
    • 6
  • b

    Bruno_

    03/26/2019, 8:30 PM
    how do you extract common configs/dependencies in gradle kotlin dsl? The problem I have is that in my
    buildSrc
    I can't for example configure sonarqube because of some properties missing
    • 1
    • 3
  • w

    wrover

    03/27/2019, 9:07 AM
    Is there a way to write an adapter for a coroutine to intercept cancellation in order to encapsulate nonstandard behavior, e.g. close an underlying socket to interrupt blocking method?
    o
    • 2
    • 3
  • d

    dmcg

    03/27/2019, 10:32 AM
    Is there anyone with a deep knowledge of Kotlin generics who could help me out with the API for #minutest? I’m trying to find the least worst solution to a co/contravariance conundrum.
    r
    • 2
    • 40
  • r

    ribesg

    03/27/2019, 11:01 AM
    Is there a way to have a
    var
    without backing field where the getter returns an optional value while the setter requires a non-optional one? Or am I just blocked on using 2 functions?
    d
    c
    • 3
    • 5
Powered by Linen
Title
r

ribesg

03/27/2019, 11:01 AM
Is there a way to have a
var
without backing field where the getter returns an optional value while the setter requires a non-optional one? Or am I just blocked on using 2 functions?
d

diesieben07

03/27/2019, 11:04 AM
So you want getter to return
Foo?
but setter to only accept
Foo
?
r

ribesg

03/27/2019, 11:04 AM
Yes. It’s doing some reflection behind the scene and there may not be a value at first, unless it has been set once using the setter. Being able to manually set a null value does not provide any value
d

diesieben07

03/27/2019, 11:06 AM
Then you can't use one var
c

Czar

03/27/2019, 11:11 AM
You could use
lateinit var
or add a
requireNotNull
check in the setter. Both seem a bit dirty to me though. See if you can refactor this somehow.
r

ribesg

03/27/2019, 11:26 AM
In the end I did (much) more reflection to go and find the default value that is affected to the field
View count: 4