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

    Gokhan Alıcı

    03/27/2019, 11:54 AM
    Hi guys, Today I noticed weird problem on equals() function it basically; class Event(val endTime: Long?){ fun isGoingEvent() = ((endTime == null) || endTime?.equals(0)) } Event(0L).isGoingEvent() ----> returns false if I change isGoingEvent() implementation with: fun isGoingEvent() = ((endTime == null) || endTime?.equals(0L)) it works as expected. It make sense because it compares Long with Long but I confused how should I compare values?
    m
    r
    • 3
    • 9
  • i

    Ilya Goncharov [JB]

    03/27/2019, 12:01 PM
    Hello, I found actual source for kotlin-eap On bintray I found https://bintray.com/kotlin/kotlin-eap this, and in top right corner there is link on https://dl.bintray.com/kotlin/kotlin-eap But additionally I found out another one https://kotlin.bintray.com/kotlin-eap/ What link is preferable?
    h
    • 2
    • 2
  • e

    elect

    03/27/2019, 4:18 PM
    why
    @JvmName
    cant do anything here?
    @JvmName("getI") fun get(): Int = 0
        @JvmName("getF") fun get(): Float = 0f // error, signature clash
    d
    r
    l
    • 4
    • 29
  • p

    Paul Woitaschek

    03/28/2019, 6:45 AM
    I want to have non exhaustive when's on a sealed classes to be an error, is that possible somehow?
    g
    s
    g
    • 4
    • 20
  • v

    Vlad

    03/28/2019, 1:31 PM
    Does Kotlin support a kind of duck typing? Because according to koans, one can simply define extension method
    operator fun MyDate.rangeTo(other: MyDate): DateRange
    and it will work without implementing any interface.
    d
    • 2
    • 1
  • a

    amadeu01

    03/28/2019, 2:24 PM
    I read this https://blog.mindorks.com/learn-kotlin-apply-vs-with But still can not understand the differences between
    apply
    and
    with
    . When should I use one over the other?
    s
    t
    +3
    • 6
    • 6
  • j

    Jorge Riveiro

    03/28/2019, 3:01 PM
    Hello, i try convert this cURL in kotlin using retrofit 2, but i cant and i really need this. Help me please. Code cURL-> curl -X POST \ URL_BASE\ -H 'Authorization: Bearer <your_acces_token>'\ -H 'content-type: application/json'\ -d '{ "process": "Attended", "rauthorityId": "<your_rauthorityId>" }'
    s
    n
    • 3
    • 7
  • p

    Paul Woitaschek

    03/28/2019, 3:55 PM
    Is it the same for you that this shows no warning in the IDE but crashes the compiler?
    d
    l
    • 3
    • 3
  • d

    Davide Giuseppe Farella

    03/28/2019, 11:22 PM
    b
    s
    • 3
    • 8
  • d

    Davide Giuseppe Farella

    03/28/2019, 11:25 PM
    Untitled.kt
    b
    • 2
    • 3
  • d

    Davide Giuseppe Farella

    03/28/2019, 11:29 PM
    Actually I had to add
    fun MutableEntity.postSomething() = postSomething
    b
    s
    • 3
    • 11
  • v

    Vlad

    03/29/2019, 6:01 AM
    class Dummy {
        fun foo() = println("Hi")
    }
    fun Dummy.apply(f :Dummy.() -> Unit) = f()
    Dummy().apply({ foo() })
    How does
    Dummy.() -> Unit
    know how it needs to dispatch the function call?
    e
    b
    • 3
    • 2
  • j

    Jacques Smuts

    03/29/2019, 11:00 AM
    Is there any way that I can use
    <reified T>
    with a
    sealed class
    ?
    d
    m
    +2
    • 5
    • 6
  • p

    Pascal How

    03/29/2019, 11:10 AM
    I’ve been reading on composition over inheritance in Kotlin and came across a few articles like this https://medium.com/the-kotlin-chronicle/why-you-should-use-class-delegation-in-kotlin-fb0a3ebf151e One way Kotlin helps to reduce boiler plate code is by using class delegation and the
    by
    keyword. This looks great and I like it so far. However, during the closing panel of KotlinConf 2018, Andrey and another guy said it was their least favourite feature. Does anyone have any opinion or bad experience with class delegation?
    ☝️ 4
    s
    g
    +2
    • 5
    • 10
  • j

    JoaoGoulart

    03/29/2019, 12:31 PM
    Hey guys. So, i Have a abstract class in Java that has a abstract method like this:
    public abstract class MyClass implements MyInterface {
        @Override
        public abstract <M extends MyInterface> MyModelType<M> getModelType();
    }
    How do i implement this in Kolin? i always get this:
    override fun <M : MyInterface?> getModelType(): MyModelType<M> {
            TODO
        }
    but this is not what i want, in Java works fine
    @Override
        public MyModelType<MyClassImpl> getModelType() {
            return null;
        }
    Any ideas on how to do it?
    r
    • 2
    • 2
  • b

    bbaldino

    03/29/2019, 7:53 PM
    i guess that's the real question: can i create an inline class whose value can be modified in place to implement something like
    inlineClassInstance++
    to increment its value
    k
    h
    • 3
    • 35
  • j

    Jared

    03/29/2019, 8:18 PM
    What version of Java do people here compile their Kotlin to?
    s
    a
    • 3
    • 3
  • s

    Smallville7123

    03/29/2019, 9:45 PM
    in particular i am unable to instance lexer(...) itself from inside the clone() function
    b
    • 2
    • 16
  • b

    bbaldino

    03/29/2019, 10:45 PM
    in fact, it's just trying to access
    Sub.member
    that causes the ClassCastException
    • 1
    • 1
  • s

    Slackbot

    03/30/2019, 3:39 AM
    This message was deleted.
    s
    s
    • 3
    • 2
  • s

    Smallville7123

    03/30/2019, 4:33 AM
    what does @ do, as i cant find its documentation in the kotlin-docs.pdf
    b
    s
    • 3
    • 3
  • d

    diesieben07

    03/30/2019, 1:14 PM
    I am working on generic data-access library (for example for accessing your SQL database) inspired by the great model system in Django (Python). The general idea is that you write your database models like this:
    object UserModel : Model {
        val name by VarcharField()
    }
    From that I am doing to generate code like this (using an annotation processor):
    data class User(val name: String)
    If I now have a call like
    dataSource.findAll(UserModel)
    how can I express to the compiler that this returns
    List<User>
    ?
    p
    • 2
    • 8
  • s

    serebit

    03/30/2019, 5:00 PM
    So kotlinx.time is in the design phase at the moment iirc. How are the logging and fileIO libs progressing?
    d
    • 2
    • 1
  • s

    Smallville7123

    03/31/2019, 4:03 AM
    as im trying to find a way to instance my classes in a way that is local to the parser class, such that when parser().clone() is called, all instances associated with parser() are reassigned to the new parser() returned by clone(), so i do not need to recreate my instances every time i clone my parser
    r
    d
    • 3
    • 5
  • t

    tipsy

    03/31/2019, 11:52 AM
    is it possible to create different callbacks based on an enum type?
    on(Event.TYPE_ONE) { int ->
        // an int is available here
    }
    
    on(Event.TYPE_TWO) { string ->
        // a string is available here
    }
    s
    l
    • 3
    • 9
  • m

    Mustafa

    04/01/2019, 1:55 AM
    Im teaching my non-technical coworkers programming 101 with Kotlin, followed by android development. Can anyone recommend me some slides, material or tips for doing this? Most reference material for Kotlin is Kotlin for Java developers. Thankyou in advanced!
    c
    • 2
    • 1
  • n

    norricorp

    04/01/2019, 8:46 AM
    According to the building web app with spring boot and kotlin tutorial, there is a spring channel. But does not appear to be in the list of channels. Am I missing something?
    t
    • 2
    • 3
  • j

    Jacques Smuts

    04/01/2019, 11:21 AM
    I know about infix operators, as well as typealias in Kotlin, but my understanding is that I wouldn’t be able to do something equivalent in Kotlin. We can’t overload or change the keywords at all. Right?
    :yes: 2
    s
    h
    +6
    • 9
    • 19
  • r

    ribesg

    04/01/2019, 2:11 PM
    Why can’t I pass a value of type
    Map<String, String?>
    as parameter of a function taking
    Map<Any?, *>
    ? I assume I can safely do an unchecked cast here, but I wonder why I need it at all
    s
    k
    +2
    • 5
    • 26
  • d

    dumptruckman

    04/01/2019, 4:12 PM
    once again I have run into a situation where the lack of package-private access is a really bad thing
    ➕ 1
    a
    • 2
    • 5
Powered by Linen
Title
d

dumptruckman

04/01/2019, 4:12 PM
once again I have run into a situation where the lack of package-private access is a really bad thing
➕ 1
I have an EmailTemplate class in my email-service module. It has members that should not be part of its public API. The members only need to be accessed by a class in the same package (and module). However, they’re open because they’re intended to be overriden. Unfortunately, there is no way to now create templates in other modules.
To do this I now have to have an internal getter method to access a protected open val.
Can we just all agree that this is stupid?
🇳🇴 6
this is how you get Java’s
protected
functionality back in Kotlin:
a

Artglorin

04/01/2019, 4:33 PM
Maybe the better way is not to create protected field but redesign your API and provide a well fitted EmailTemplateBuilder?
➕ 6
View count: 14