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

    droidrcc

    01/26/2018, 5:40 PM
    it is possible to override execute() function during this declaration ?
    f
    • 2
    • 4
  • s

    stephan_marshay

    01/26/2018, 8:46 PM
    Yeah, I missed that part, my bad…
    j
    • 2
    • 1
  • j

    joelpedraza

    01/26/2018, 8:58 PM
    @Czar An I looking in the right place: https://github.com/JetBrains/kotlin/blob/9a8699a2abc9e9a7934647143e0e0ac44e81d3f5/plugins/noarg/noarg-cli/src/NoArgPlugin.kt
    c
    • 2
    • 1
  • h

    Hassan

    01/26/2018, 10:53 PM
    Kotilin's Syntax is similar to Java??
    a
    • 2
    • 1
  • e

    edik

    01/26/2018, 11:56 PM
    class Jikaz {
    
       var id: Int? = null
    
        init {
           id = nextId?.inc()
        }
    
        companion object {
          var nextId : Int? = 1
        }
    }
    
    fun main(args: Array<String>) {
    
        Jikaz()
        Jikaz()
        println("result z =${Jikaz().id!!}")
    
    }
    c
    • 2
    • 1
  • e

    edik

    01/27/2018, 12:13 AM
    ahha, ok thanks, and my apologies for the lack of formatting IR and others... will not happen again 🙂
    o
    • 2
    • 7
  • e

    edik

    01/27/2018, 12:57 AM
    I'd appreciate any pointers to where I can find the source for the inc() operator method call because it's semantics are definitely different from the pre/post increment ++ operator
    o
    • 2
    • 3
  • e

    edik

    01/27/2018, 1:08 AM
    Does this have side-effects (i.e. on the message receiver) or does it simply return an incremented value?
    o
    • 2
    • 35
  • r

    richardfinegan

    01/27/2018, 6:04 PM
    I don't think "directly inside a package" means anything that specific...anyway the whole line is "Functions, properties and classes, objects and interfaces can be declared on the "top-level", i.e. directly inside a package:" which doesn't make any distinction between classes/objects vs functions which @James Coggan showed earlier works.
    c
    • 2
    • 2
  • z

    zake

    01/28/2018, 6:14 AM
    What’s the best way to do something among the lines of
    class Foo {
        val bar = mutableListOf<Bar>()
            get() {
                return listOf(*bar.toTypedArray())
            }
    }
    ? It would seem that the only way is to really just do
    val bar = mutableListOf<Bar>()
    ...
    fun getBar(): List<Bar> = bar
    , but the result is that it you get two getters with the same signature on the JVM Update: If you just add the
    @JvmField
    decorator, you don’t have to deal with that, but is there a way to do it as closely to the top idea? Because you can still just get the mutableList as a property apparently Update: Backing the field is probably the solution.
    j
    • 2
    • 1
  • b

    benleggiero

    01/28/2018, 7:14 AM
    Are there any downsides to using
    import packageWithWayTooMuchInside.*
    ?
    l
    i
    +3
    • 6
    • 11
  • r

    raulraja

    01/29/2018, 1:42 AM
    @Dave Leeds
    var occupant: T
    happens in invariant position and you are stating that
    crate: Crate<in Dog>
    is contravariant. If you change
    crate: Crate<in Dog>
    to
    crate: Crate<out Dog>
    or just
    crate: Crate<Dog>
    it will compile. I'm guessing star projections are equivalent to existential types and unaffected by variance and
    Animal
    is all it can infer there based on your
    T : Animal
    constrain.
    d
    m
    • 3
    • 4
  • d

    davidase

    01/29/2018, 11:00 AM
    is there a "standard" library for parsing args?
    🇳🇴 1
    g
    j
    +4
    • 7
    • 7
  • s

    SnowmanX95

    01/29/2018, 5:02 PM
    Well, one thing which is unfortunate is the cost of the companion object. Especially when it comes to Android where in many cases the only thing you want to put there is the TAG string. And yet one more class and one more instances is going to get created just for the sake of one constant.
    s
    k
    +2
    • 5
    • 6
  • i

    ilya.gorbunov

    01/29/2018, 9:26 PM
    you're comparing
    event
    with
    true
    and that results in else block being executed
    ✅ 4
    😮 1
    a
    s
    c
    • 4
    • 3
  • s

    snowe

    01/29/2018, 9:27 PM
    can you not write arbitrary expressions like this if you are not comparing directly to the when parameter?
    c
    • 2
    • 2
  • s

    Shawn

    01/29/2018, 9:31 PM
    seems like the right use case for an if/else assignment
    c
    • 2
    • 1
  • p

    pakoito

    01/30/2018, 12:22 AM
    through a higher order function with a receiver parameter?
    s
    • 2
    • 5
  • p

    pakoito

    01/30/2018, 12:22 AM
    it requires hinting both in and out types 😞
    d
    • 2
    • 1
  • g

    Gizmo

    01/30/2018, 1:08 PM
    Hi Everyone! I'm trying to convert my gradle buildscript to kotlin. This was my original script: https://github.com/sandrobraendli/ExcelTaImport/blob/master/build.gradle And this is what I came up with so far: https://github.com/sandrobraendli/ExcelTaImport/blob/gradle-kotlin/build.gradle.kts The problem is, when I try to compile, I get the following error (multiple times): e: C:\Users\sbraendli_adm.ZSO\IdeaProjects\ExcelTaImport\src\main\java\io\braendli\importer\Importer.kt: (33, 45): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: @InlineOnly public inline fun <T : Closeable?, R> ???.use(block: (???) -> ???): ??? defined in kotlin.io From what I understand, this is because the default jvmTarget for Kotlin is 1.6. Despite some intense googling and trying, I couldn't make the error go away. I hope someone can help.
    :gradle: 1
    a
    • 2
    • 2
  • i

    ilya.gorbunov

    01/30/2018, 1:56 PM
    Yes, at the moment. In Kotlin you should use functional types instead, e.g.
    (String) -> Any
    r
    o
    s
    • 4
    • 4
  • d

    dave08

    01/30/2018, 6:01 PM
    How do I import a Kotlin class that's not in any package? Or should all classes be in a package, but just not in all the nested directories?
    j
    • 2
    • 1
  • l

    Leeeloo Minai

    01/30/2018, 8:10 PM
    I will try in this channel. I cannot understand what's going on in the declaration of Filter here: https://github.com/http4k/http4k/blob/master/http4k-core/src/main/kotlin/org/http4k/core/Http4k.kt To make it worse, when I isolated that declaration and tried to compile it, the compiler insists that "'invoke' overrides nothing". Here's my simple test: http://rextester.com/live/FQUC99965 So now I am stuck - I noticed that inheritance hierarchy in IntelliJ mentions some Function1 interface that seems not to be inherited there (but just spitballing here.)
    d
    • 2
    • 1
  • l

    Leeeloo Minai

    01/30/2018, 8:21 PM
    (Never mind about my comment above - my example was missing the derivation part.)
    r
    • 2
    • 1
  • o

    Olekss

    01/30/2018, 8:25 PM
    hey is it expected that I can't do ::field.isInitialized check for private lateinit var?
    d
    • 2
    • 1
  • a

    alex2069

    01/30/2018, 11:45 PM
    I'd probably proguard it and package it in the same jar
    l
    • 2
    • 1
  • v

    vitrox1

    01/31/2018, 9:05 AM
    Hello People! have all a good day, I want to know when is going to be more or less available the support for “@NonNull” annotations in the way that not !! is needed anymore for the cases when we have that annotation! Thanks!
    m
    l
    • 3
    • 4
  • p

    pniederw

    01/31/2018, 11:31 AM
    is there a good way to convert kotlin to java code?
    h
    l
    • 3
    • 2
  • l

    Lucas Ribeiro

    01/31/2018, 12:30 PM
    just to make sure that is a issue with the
    @Json
    annotation, if you remove the annotation and name the variable with the name that you receive on json, it's work ?
    j
    • 2
    • 10
  • n

    north

    01/31/2018, 1:08 PM
    I have the following declaration
    data class XData(val one: Int)
    abstract class MyBinder : Binding<Any, List<XData>>
    Here is the bytecode genrated for it: // declaration: MyBinder implements Binding<java.lang.Object, java.util.List<? extends XData>> is there any way to enforce the type to be
    Binding<java.lang.Object, java.util.List<XData>>
    instead of
    Binding<java.lang.Object, java.util.List<? extends XData>>
    d
    • 2
    • 2
Powered by Linen
Title
n

north

01/31/2018, 1:08 PM
I have the following declaration
data class XData(val one: Int)
abstract class MyBinder : Binding<Any, List<XData>>
Here is the bytecode genrated for it: // declaration: MyBinder implements Binding<java.lang.Object, java.util.List<? extends XData>> is there any way to enforce the type to be
Binding<java.lang.Object, java.util.List<XData>>
instead of
Binding<java.lang.Object, java.util.List<? extends XData>>
d

diesieben07

01/31/2018, 1:10 PM
The
@JvmSuppressWildcards
annotation does what you want.
n

north

01/31/2018, 1:11 PM
Thank you. It's exactly what I needed.
View count: 1