https://kotlinlang.org logo
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
getting-started
  • c

    cdurham

    08/10/2017, 5:09 PM
    Are there any good examples of using
    @Deprecated
    that can be auto-fixed by intelliJ?
    v
    • 2
    • 2
  • v

    v79

    08/10/2017, 7:27 PM
    Should a String's isNullOrEmpty() count as a null check in an if... else block?
    if(bridgeName == null || bridgeName.isEmpty()) {
    			errors.put("add-search-name","Name must not be blank")
    		} else {
    			if(4 > bridgeName.length) {
    
    			}
    works fine, but if I replace the if condition with
    if(bridgeName.isNullOrEmpty())
    the name length check isn't null safe.
    k
    • 2
    • 3
  • a

    ar-g

    08/11/2017, 5:17 AM
    Why use backing field and not name of property?
    class User(val name: String) {
        var address: String = "unspecified"
            set(value: String) {
                println(address)//works
                address = value//doesn't work
            }
    }
    a
    v
    • 3
    • 4
  • l

    lovis

    08/11/2017, 11:13 AM
    interestingly, if you write
    if(long.equals(int)) {
      ...		
    }
    the IDE suggests to replace it with
    ==
    , even though that doesn’t work 🙈
    d
    k
    k
    • 4
    • 6
  • m

    mquigley

    08/11/2017, 6:25 PM
    Can anyone explain why the literal
    0xAABBCCDD_11223344L
    cannot exist in Kotlin? Neither can the value of
    Long.MIN_VALUE
    , which is actually represented by
    -9223372036854775807L - 1L
    ?
    d
    r
    k
    • 4
    • 8
  • g

    gaurav9822

    08/12/2017, 5:47 AM
    Want to learn kotlin
    :kotlin: 4
    r
    s
    • 3
    • 2
  • g

    gp

    08/13/2017, 4:00 AM
    Hi All ... I am Kotlin newbie though programing in java since last 15 years .....and Angular Js ...I have few basic questions we are majorly using angular js /type script ...does kotlin has any bridge for that ..ideas around how to leverage existing angular code with kotlin ?
    v
    • 2
    • 1
  • r

    rebcabin

    08/13/2017, 4:11 PM
    Question:
    count()
    versus
    size
    for collections? Seems there are two ways to get the number of elements in a collection:
    count()
    called without a predicate argument and
    size
    , looks like a field, attribute, property. Any reason to prefer one over the other?
    d
    • 2
    • 1
  • j

    jimn

    08/14/2017, 6:11 AM
    anyone awake?
    😴 1
    o
    o
    • 3
    • 2
  • a

    arekolek

    08/14/2017, 9:41 AM
    But you can have more than one companion object, right? I guess if you can’t impose requirements on properties, then you can’t on companion objects.
    r
    • 2
    • 3
  • j

    jk

    08/14/2017, 2:08 PM
    can you show the code for
    missingParamError
    and
    incorrectPassword
    , and what the similarity/differences between them are?
    d
    • 2
    • 10
  • b

    bachhuberdesign

    08/15/2017, 1:50 AM
    What is a good way to get around not being able to use reified type parameters in an interface? I want to have a method like
    override inline fun <reified T> foo(key: String, value: T): T {
        }
    but it's not possible since you can't
    inline
    an interface function
    v
    k
    • 3
    • 4
  • r

    raul782

    08/15/2017, 3:07 AM
    Hi guys! I haven't found any implementation of a json-schema-form in kotlin?, do you know if there is one available?
    v
    • 2
    • 2
  • k

    karelpeeters

    08/15/2017, 9:45 AM
    Yup, while should work.
    d
    i
    • 3
    • 5
  • k

    karelpeeters

    08/15/2017, 10:21 AM
    You can a sequence to avoid creating a temporary
    List
    if you're going with
    forEach
    .
    👍 1
    s
    l
    • 3
    • 4
  • m

    matthew

    08/15/2017, 5:57 PM
    something with
    fold
    maybe?
    l
    b
    • 3
    • 3
  • o

    oday

    08/15/2017, 8:28 PM
    is there a way that I can refer to a Pair’s
    first
    and
    second
    by something custom?
    v
    • 2
    • 3
  • o

    oday

    08/16/2017, 8:14 AM
    what do you guys use for testing?
    q
    • 2
    • 1
  • m

    menegatti

    08/16/2017, 9:53 AM
    data.groupBy { it[0] }.mapValues { (_, value) -> value.map { it[1] } }
    👍 2
    t
    k
    +2
    • 5
    • 14
  • d

    delater

    08/17/2017, 9:38 AM
    I would like to have default return like in java in kotin but when's else doesnt do the thing as it has to be in separate case
    n
    l
    • 3
    • 3
  • o

    oday

    08/17/2017, 1:26 PM
    how can I break from a foreach 😮
    e
    l
    • 3
    • 5
  • d

    diesieben07

    08/17/2017, 5:49 PM
    Or just do a nullcheck on the result of
    get
    instead of the
    containsKey
    , saves you one hash lookup as well.
    v
    • 2
    • 2
  • d

    darkmoon_uk

    08/17/2017, 10:06 PM
    Any 'standard advice' for 'Kotling Plugin Update not installed' on Android Studio? It downloads it but fails to install. I checked the logs, no reference to it. My project deps. are already 1.1.4.
    k
    • 2
    • 2
  • m

    mcscruff

    08/18/2017, 12:17 AM
    hi all, im new to kotlin, and trying to read a JSON file, i have seen the klaxon lib, but how do i add it to my project
    k
    • 2
    • 1
  • j

    Juan

    08/18/2017, 4:16 AM
    Hello, Could you please explain me what's the companion object intended for?
    k
    • 2
    • 1
  • t

    techie01

    08/18/2017, 11:59 AM
    what is difference between arraryListOf() and listOf()
    k
    k
    • 3
    • 5
  • d

    dathoang.se

    08/20/2017, 8:21 AM
    @qwert_ukg not related to your question. But you’re violating “Single Responsibility Principle” because you put two distinct responsilities into a single object, NotificationRespository should only be responsible of storing & loading data. The responsibility of sending notification should be delegated to other objects.
    q
    • 2
    • 1
  • o

    oday

    08/20/2017, 8:40 PM
    i get a randomblock, the shape, and use its name to feed to the move function so it knows at which cell locations to increment, and eventually redraw, therefore moving the current shape
    k
    • 2
    • 9
  • b

    benleggiero

    08/21/2017, 3:25 AM
    Why won't this compile?
    class Foo(var values: MutableList<String>)
    
    class Bar(var foo: Foo) {
        fun bar() {
            foo.values += "Baz"
        }
    }
    k
    • 2
    • 6
  • b

    benleggiero

    08/21/2017, 4:16 AM
    And why won't this compile either?
    class Foo(val bars: Map<Int, Bar<*>>) {
        
        fun <Baz> qux(baz: Baz) {
            val bar2 = bars[2]!!
            bar2.bazes += baz
        }
        
        interface Bar<Baz> {
            var bazes: MutableList<Baz>
        }
    }
    k
    • 2
    • 2
Powered by Linen
Title
b

benleggiero

08/21/2017, 4:16 AM
And why won't this compile either?
class Foo(val bars: Map<Int, Bar<*>>) {
    
    fun <Baz> qux(baz: Baz) {
        val bar2 = bars[2]!!
        bar2.bazes += baz
    }
    
    interface Bar<Baz> {
        var bazes: MutableList<Baz>
    }
}
k

karelpeeters

08/21/2017, 7:31 AM
Read this: https://kotlinlang.org/docs/reference/generics.html#type-projections
b

benleggiero

08/21/2017, 1:24 PM
Thanks! I'm still not used to there being useful existing knowledge about Kotlin compiler errors :P
View count: 2