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

    pniederw

    10/31/2017, 2:23 AM
    I’m having issues with intellij not recompiling when I edit an inline function. I need to “rebuild project” for the change to take effect. known issue?
    o
    a
    • 3
    • 2
  • p

    pniederw

    10/31/2017, 3:18 AM
    (trying to adapt https://stackoverflow.com/questions/36253310/how-to-get-actual-type-arguments-of-a-reified-generic-parameter-in-kotlin to get a
    KType
    rather than a
    Type
    )
    m
    • 2
    • 14
  • a

    avovk

    10/31/2017, 11:53 AM
    @neuber This line here:
    buttone1.setOnClickListener { viewModel.setDrawable() }
    You can change it to something like this:
    buttone1.setOnClickListener { viewModel.setDrawable(context = this) }
    Then change the function you are currently editing to this:
    fun setDrawable(context: Context) {
        back.setDrawable(context.getResources()./*the rest*/)
    }
    That should help
    n
    • 2
    • 1
  • p

    poohbar

    10/31/2017, 1:11 PM
    This guide shows quite different settings form what the wizard did: https://kotlinlang.org/docs/reference/using-maven.html E.g. it specifies
    sourceDir
    for the Kotlin plugin, should I do that? And why does it replace the execution for the java compiler plugin in the guide?
    <!-- Replacing default-compile as it is treated specially by maven -->
    How specially? What? What does that mean? Why is the documentation so bad?
    i
    • 2
    • 3
  • p

    poohbar

    10/31/2017, 1:22 PM
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
            <execution>
                <id>default-compile</id>
                <phase>none</phase>
            </execution>
    What does this do? There is nothing about
    default-compile
    goal anywhere in Maven docs.
    c
    • 2
    • 2
  • h

    hannesstruss

    10/31/2017, 1:35 PM
    I'm trying to access the children of a sealed class via a typealias, but it fails with
    Unresolved reference
    . Is that generally impossible?
    sealed class LoginScreenAction {
      object NameEntered : LoginScreenAction()
      object SubmitClicked : LoginScreenAction()
    }
    
    private typealias Action = LoginScreenAction
    
    fun main() {
      println("My action is: ${Action.NameEntered}")
    }
    m
    • 2
    • 2
  • m

    mike_shysh

    10/31/2017, 5:21 PM
    Is there a simple way of modifying a file?
    a
    • 2
    • 4
  • k

    karelpeeters

    10/31/2017, 10:06 PM
    Is there no way to construct an anonymous instance of a SAM-ish abstract class from a lambda? For example:
    //java code
    public abstract class Test {
        public abstract void run()
    }
    
    //kotlin code
    fun testFoo(test: Test) = test.run()
    
    fun main(args: Array<String>) {
        testFoo(object : Test() {
            override fun run() {
                println("hey")
            }
        })
    }
    It just feels unnecessary, are there plans to do something about this?
    e
    b
    • 3
    • 11
  • a

    alphi

    11/01/2017, 9:32 AM
    Hi everyone, I'm creating a kotlin cheatsheet for myself while I learn the language. Kindly feel free to contribute to the repo. https://github.com/alfredayibonte/kotlin-cheat-sheet
    g
    • 2
    • 7
  • c

    Czar

    11/01/2017, 1:13 PM
    Hi. For a subtree of our class hierarchy we have interface method
    apply
    whose argument is a SAM from guava. Since some of us started using :kotlin: we bump into the conflict with Kotlin's
    apply
    quite often. I'm considering the resolution options and so far found only two. Did I miss anything? 1. rename member
    apply
    to something like
    applyFunction
    (involves convincing several teamleads who do not use :kotlin: ) 2. specify the receiver type (
    someInstanceOfBase.apply<Base> { ... }
    ) (suggested by @marstran) 3. accept that this is the reality and use
    also
    instead of
    apply
    4. duplicate Kotlin's
    apply
    and rename that (suggested by @karelpeeters) Here's the recipe for the disaster at hand 🙂 (irrelevant parts omitted for brevity) :java:
    import com.google.common.base.Function;
    public abstract class Base {
    	public <T, F> T apply(Function<F, T> function) {
    		return function.apply((F) this);
    	}
    }
    s
    • 2
    • 3
  • m

    marstran

    11/01/2017, 1:55 PM
    Does
    someInstanceOfBase.apply<Base> { ... }
    work?
    c
    • 2
    • 3
  • p

    poohbar

    11/01/2017, 3:36 PM
    I have this Kotlin data class:
    class Person(override val id: String, val name: String) : HasId
    and this Java interface:
    public interface HasId {
        String getId();
    }
    How do I implement the interface? The above example gives me
    'id' overrides nothing
    d
    k
    • 3
    • 2
  • h

    hagabaka

    11/01/2017, 11:33 PM
    is it possible to access a property or function by string containing its name at run time, like in JavaScript?
    k
    • 2
    • 8
  • s

    settermjd

    11/02/2017, 12:15 PM
    I'm trying to emulate https://github.com/JetBrains/kotlin-examples/blob/master/maven/hello-world/pom.xml in my own project, but keep encountering
    java.lang.ClassNotFoundException: MainKt
    (my main class is
    src/main/Main.kt
    , the package is called
    main
    . Any suggestions?
    c
    • 2
    • 4
  • d

    dorsamet

    11/02/2017, 3:32 PM
    Hey guys, this is a coroutines question: Do coroutines cache the "await"ed results? If that is not the case, how should caching be done?
    r
    • 2
    • 2
  • h

    hagabaka

    11/02/2017, 5:58 PM
    Is it possible to have an interface which can only be implemented by subclasses of a certain class, and be able to use properties/methods of that super class in the interface? For example in my Android app, a few activities do the same things in onCreate etc, but it seems restrictive to write an Activity subclass and have them all inherit it
    d
    • 2
    • 1
  • p

    pavel

    11/02/2017, 6:36 PM
    I think even Windows does the right thing when it encounters
    \n
    k
    • 2
    • 1
  • s

    Shawn

    11/02/2017, 6:36 PM
    but I wasn’t sure if in Kotlin,
    \n
    represented literally ASCII
    0x0A
    or if it ends up being translated to the proper newline depending on platform
    j
    • 2
    • 2
  • a

    Andreas Sinz

    11/03/2017, 1:53 PM
    @ayrat555 an
    object
    by the definition of Kotlin is a class that has a single instance (like a Singleton) and that instance is created automatically at startup, so there is no way to have abstract stuff inside an Object
    a
    a
    • 3
    • 3
  • f

    Fré Dumazy

    11/04/2017, 10:26 AM
    Perhaps I'm not the first one asking but were the talks at KotlinConf filmed and will the videos be available for everybody?
    k
    • 2
    • 1
  • z

    ziggy42

    11/04/2017, 3:08 PM
    Inner classes are more expensive, I guess
    k
    r
    t
    • 4
    • 9
  • j

    jw

    11/04/2017, 4:40 PM
    it's a construct of the language but not the bytecode or runtime
    t
    • 2
    • 1
  • r

    ron

    11/04/2017, 4:42 PM
    hi Jake, found it 🙂
    t
    • 2
    • 1
  • b

    bdawg.io

    11/04/2017, 8:15 PM
    @tgmcians you have to cast it in some way. ie,
    responseBody?.let {
        view?.onUnknownError(getErrorMessage(it))
    }
    ❤️ 1
    👍 1
    t
    • 2
    • 1
  • t

    tmseiler

    11/04/2017, 8:15 PM
    if I wanted to do basic 2d graphics, similar to canvas on the web, what would I choose these days?
    a
    • 2
    • 2
  • j

    jo

    11/04/2017, 9:54 PM
    O(n)?
    k
    • 2
    • 1
  • n

    nish

    11/05/2017, 3:16 AM
    Thanks
    r
    • 2
    • 7
  • k

    kartikpatodi

    11/05/2017, 6:56 AM
    Can anyone explain what is
    reified
    I'm unable to understand the concept behind this one
    k
    • 2
    • 10
  • a

    aeruhxi

    11/05/2017, 1:45 PM
    where can I watch kotlin conf recordings?
    k
    • 2
    • 2
  • m

    Minty

    11/05/2017, 3:40 PM
    Is there anything wrong with this code?
    i
    • 2
    • 1
Powered by Linen
Title
m

Minty

11/05/2017, 3:40 PM
Is there anything wrong with this code?
i

ilya.gorbunov

11/05/2017, 9:26 PM
You'll never get
endInclusive
as a result of this function though it's named "inclusive". Otherwise it seems ok.
View count: 2