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

    mc

    04/24/2018, 10:35 AM
    I want to run kotlin script from a maven build. Does anybody know which args to pass to kotlin-maven-plugin? I tried
    mvn kotlin:script -DscriptFile=MyScript.kts
    without success
    h
    • 2
    • 1
  • a

    Artyom Lebedev

    04/24/2018, 11:48 AM
    Hello, I have a problem with logging in to https://discuss.kotlinlang.org. It gives me error "Sorry, there was an error authorizing your account. Perhaps you did not approve authorization?" Tried in several browsers, and with cookie clearing. Who can help with this?
    h
    r
    • 3
    • 2
  • k

    Kyle

    04/24/2018, 2:07 PM
    [Job Opportunity] Hi All, Ps. My Not sure if correct place to post, but am looking for a Australian / Brisbane based dev to help finish an app for one of our startups. Please PM me if interested. Many thanks 🙂
    p
    • 2
    • 2
  • m

    myanmarking

    04/24/2018, 2:12 PM
    is any1 having this problem in builds with kotlin latest v:
    e: [kapt] An exception occurred: java.lang.NoClassDefFoundError: org/jetbrains/kotlin/serialization/jvm/JvmProtoBufUtil
    	at me.eugeniomarletti.kotlin.metadata.KotlinClassMetadata$data$2.invoke(KotlinMetadata.kt:51)
    	at me.eugeniomarletti.kotlin.metadata.KotlinClassMetadata$data$2.invoke(KotlinMetadata.kt:50)
    	at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:131)
    	at me.eugeniomarletti.kotlin.metadata.KotlinClassMetadata.getData(KotlinMetadata.kt)
    	at android.arch.persistence.room.ext.KotlinMetadataProcessor$DefaultImpls.getParameterNames(KotlinMetadataProcessor.kt:33)
    	at android.arch.persistence.room.processor.PojoProcessor.getParameterNames(PojoProcessor.kt:74)
    	at android.arch.persistence.room.processor.PojoProcessor.getParamNames(PojoProcessor.kt:246)
    	at android.arch.persistence.room.processor.PojoProcessor.chooseConstructor(PojoProcessor.kt:264)
    	at android.arch.persistence.room.processor.PojoProcessor.doProcess(PojoProcessor.kt:208)
    	at android.arch.persistence.room.processor.PojoProcessor.access$doProcess(PojoProcessor.kt:74)
    	at android.arch.persistence.room.processor.PojoProcessor$process$1.invoke(PojoProcessor.kt:105)
    	at android.arch.persistence.room.processor.PojoProcessor$process$1.invoke(PojoProcessor.kt:74)
    	at android.arch.persistence.room.processor.cache.Cache$Bucket.get(Cache.kt:46)
    	at android.arch.persistence.room.processor.PojoProcessor.process(PojoProcessor.kt:102)
    	at android.arch.persistence.room.processor.EntityProcessor.doProcess(EntityProcessor.kt:68)
    	at android.arch.persistence.room.processor.EntityProcessor.access$doProcess(EntityProcessor.kt:50)
    	at android.arch.persistence.room.processor.EntityProcessor$process$1.invoke(EntityProcessor.kt:57)
    	at android.arch.persistence.room.processor.EntityProcessor$process$1.invoke(EntityProcessor.kt:50)
    	at android.arch.persistence.room.processor.cache.Cache$Bucket.get(Cache.kt:46)
    	at android.arch.persistence.room.processor.EntityProcessor.process(EntityProcessor.kt:56)
    	at android.arch.persistence.room.processor.DatabaseProcessor.processEntities(DatabaseProcessor.kt:248)
    	at android.arch.persistence.room.processor.DatabaseProcessor.doProcess(DatabaseProcessor.kt:63)
    	at android.arch.persistence.room.processor.DatabaseProcessor.process(DatabaseProcessor.kt:53)
    	at android.arch.persistence.room.RoomProcessor$DatabaseProcessingStep.process(RoomProcessor.kt:57)
    	at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:318)
    f
    • 2
    • 2
  • l

    leosan

    04/24/2018, 4:36 PM
    is there a way to create a
    Delegates.observable
    of a read-only property? e.g.
    data class Foo(bar:Boolean, car:Boolean)
    val foo by Delegates.observable(Foo(false,false)){...}
    foo.bar = true
    g
    d
    • 3
    • 4
  • n

    nkiesel

    04/24/2018, 7:40 PM
    I'm trying use Koltin Poet to generate data classes for JPA. I'm stuck at trying to create a
    val owners: MutableSet<MyObject> = mutableSetOf()
    because
    MutableSet::class
    is
    class kotlin.collections.Set
    and not
    class kotlin.collections.MutableSet
    . Any idea why that is the case (or even better what I can do to fix this)?
    k
    • 2
    • 5
  • o

    orangy

    04/24/2018, 9:10 PM
    @Ruckus as for original vector example, I wonder why do you have
    var
    everywhere, if you always create a copy? If you had
    val
    properties, you could make
    ident
    and
    zero
    just properties and never create these classes again and again
    r
    • 2
    • 1
  • k

    Kyle

    04/25/2018, 3:57 AM
    message has been deleted
    😠 3
    😡 1
    s
    • 2
    • 1
  • a

    Artyom Lebedev

    04/25/2018, 7:20 AM
    Logging in to https://discuss.kotlinlang.org still does not work. Does anyone know the administrator contact? I'm not sure this problem affects all users, and may be they are not aware of it.
    b
    m
    r
    • 4
    • 6
  • p

    pga4711

    04/25/2018, 11:40 AM
    This is the kotlinglang workspace. Is there a similar Slack workspace more focused on Android? For those not programming in kotlin yet for example.
    p
    m
    • 3
    • 2
  • d

    droidrcc

    04/25/2018, 12:32 PM
    I tried to check in https://kotlinlang.org/docs/reference/coding-conventions.html, but this case is not mentioned.
    a
    • 2
    • 1
  • y

    ylemoigne

    04/25/2018, 1:02 PM
    I would like to get a behavior like if it was legal to write
    fun foo(p:String?):Bar? { .. }
    fun foo(p:String):Bar { .. }
    Is there an annotation or something to achieve this ?
    g
    • 2
    • 1
  • e

    elect

    04/25/2018, 1:06 PM
    I have an
    ArrayList<Int>
    , is there any stlib to get rid of duplicated elements?
    p
    d
    • 3
    • 6
  • y

    ylemoigne

    04/25/2018, 1:06 PM
    Well to garantee non null return if the parameter is not null.
    g
    • 2
    • 1
  • j

    james-nguyen

    04/25/2018, 2:30 PM
    Hi guys, do you have any open sources that is needing contributors? if so, inbox me.
    g
    p
    • 3
    • 2
  • d

    dwickern

    04/25/2018, 4:21 PM
    It seems that, if an API isn't annotated `@Nullable`/`@NotNull`, Kotlin assumes that it's
    @NotNull
    . Is this really the default? Is there a compiler option to fix this?
    g
    • 2
    • 1
  • g

    gildor

    04/25/2018, 4:41 PM
    Correct, but it doesn't mean that Kotlin concider this type as non nullable, it allows you to decide
    s
    d
    p
    • 4
    • 10
  • e

    edwardwongtl

    04/26/2018, 5:39 AM
    I got a question about
    @Deprecated
    and
    ReplaceWith()
    , while replacing normal functions works fine, replacing infix function will be like this
    @Deprecated(..., replaceWith = ReplaceWith("bar(x)"))
    infix fun Foo.foo(x: Int) = ...
    infix fun Foo.bar(x: Int) = ...
    
    foo foo 10
    // After replacement becomes
    foo.bar(10)
    is there anyway for the IDE do the replacement such that it becomes
    foo bar 10
    ?
    g
    • 2
    • 17
  • v

    visakha

    04/26/2018, 6:24 AM
    Hello Kotlin experts, I am trying to obtain the result from a
    flatMap -> comparator
    . please see the gist at https://gist.github.com/visakha/8ac7f823e02192beb23a3f869fc4a196
    i
    • 2
    • 8
  • s

    Shawn

    04/26/2018, 9:49 AM
    I think
    List.asSequence()
    might be what you’re looking for - I think using a sequence should only evaluate lazily
    m
    • 2
    • 1
  • s

    Shawn

    04/26/2018, 9:50 AM
    of course, you could just do this with a regular ol’ for loop if parsing is that expensive
    m
    • 2
    • 1
  • m

    myanmarking

    04/26/2018, 9:54 AM
    i just need the latest for each key
    v
    • 2
    • 2
  • m

    mcblum

    04/26/2018, 4:07 PM
    well, that one is solved. for whatever reason the request var needed a
    toString
    even though it was a string.
    r
    • 2
    • 2
  • b

    bjonnh

    04/26/2018, 8:52 PM
    ok, I'll just use moshi then, thanks
    d
    • 2
    • 1
  • r

    robstoll

    04/26/2018, 11:39 PM
    Anybody knows how to write a
    @Deprecated(..., ReplaceWith("OtherClass(arg1, arg2"))
    which takes the type parameter of the deprecated class into account? Currently it adds it oddly to the replace with transformation, it results in
    OtherClass<T>
    even though I have not specified
    <T>
    in the
    ReplaceWith
    i
    • 2
    • 2
  • k

    karelpeeters

    04/27/2018, 7:31 AM
    Ah wait looks like that's only for delegating to a property of
    this
    .
    d
    p
    • 3
    • 4
  • f

    Filip Husnjak

    04/27/2018, 9:54 AM
    Hello guys! Is there a way to get a companion objects parent class from within a companion declaration?
    d
    • 2
    • 4
  • j

    janvladimirmostert

    04/27/2018, 9:57 AM
    just want to print, but with a warning next to it to not use print
    c
    • 2
    • 2
  • c

    Czar

    04/27/2018, 10:08 AM
    By doing that you're making those people loose time tracking why there is no output. Just add stylecheck/linting and prevent them from compiling/building code with print/println in it. This is what we have set up in our project, checkstyle detects and complains about print/println and IntelliJ highlights them also.
    ➕ 1
    j
    g
    • 3
    • 16
  • o

    o.semen

    04/27/2018, 10:10 AM
    Why it does not allow to assign descendant class ?
    interface TopicDelegate<T: ProfileItem> {
        val title: Int
    }
    
    class DistrictDelegate(val api: INetworkApi): TopicDelegate<District> {
        override val title: Int = R.string.choose_districts
    }
    
    abstract class TopicFragment<T: ProfileItem> : BaseFragment() {
        private var modeDelegate: TopicDelegate<T> = DistrictDelegate(mNetworkApi) //does not work
        //Type mismatch. Required: TopicDelegate<T> Found: DistrictDelegate
    }
    d
    • 2
    • 3
Powered by Linen
Title
o

o.semen

04/27/2018, 10:10 AM
Why it does not allow to assign descendant class ?
interface TopicDelegate<T: ProfileItem> {
    val title: Int
}

class DistrictDelegate(val api: INetworkApi): TopicDelegate<District> {
    override val title: Int = R.string.choose_districts
}

abstract class TopicFragment<T: ProfileItem> : BaseFragment() {
    private var modeDelegate: TopicDelegate<T> = DistrictDelegate(mNetworkApi) //does not work
    //Type mismatch. Required: TopicDelegate<T> Found: DistrictDelegate
}
d

diesieben07

04/27/2018, 10:12 AM
DistrictDelegate
is a
TopicDelegate<District>
, but a
TopicDelegate<T>
is required.
T
might not be
District
.
o

o.semen

04/27/2018, 11:43 AM
District extends ProfileItem
so
TopicDelegate<District>
should fit into
TopicDelegate<T: ProfileItem>
right ?
d

diesieben07

04/27/2018, 11:44 AM
No.
T
is a parameter, it may stand for anything that extends
ProfileItem
. So if
T
is actually a
SomeOtherProfileItem
, you can't put a
District
in there.
View count: 3