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
announcements
  • k

    karelpeeters

    11/07/2018, 8:05 PM
    Kotlin protects you from mistakenly operating on nullable types
    fun foo(): String {
        null?.let {
            return it
        }
    }
    
    println(foo().length) //NullPointerException
    r
    p
    • 3
    • 10
  • k

    Kevin Huang

    11/08/2018, 2:25 AM
    Do you like "Return at Labels" ? Specially in lambdas. It is too similar to
    goto
    . And in lambdas,can't call "return" directly. In some complex cases , can't return a value immediately , need some ugly code to solve. Any suggests for this situation? Thanks.
    g
    s
    • 3
    • 22
  • s

    stevecstian

    11/08/2018, 2:49 AM
    Should we have kotl.in/maven and kotl.in/gradle?
    :yes: 2
    s
    h
    • 3
    • 15
  • c

    cygnus

    11/08/2018, 3:51 AM
    in documentation, how would i reference a specific parameter of a method?
    g
    • 2
    • 4
  • m

    Massimo Carli

    11/08/2018, 11:24 AM
    Hi all, just a curiosity. Why the type of
    String::class
    is
    KClass<String>
    while the type of
    "Hello"::class
    is
    KClass<out String>
    ? This means that what
    "Hello"::class
    returns is a
    KClass<T>
    where
    T
    is a subtype of
    String
    . But
    String
    is final and it doesn't have subtypes. 🤔
    k
    • 2
    • 2
  • b

    bartvh

    11/08/2018, 2:44 PM
    I'm trying to implement a custom property delegate, but the compiler complains that it doesn't have a
    getValue(receiver, property)
    method. While that's true, I only have a
    var value: Boolean
    , I've looked into the source code for Lazy an it also only has a
    var value: T
    . Why can't I do it like this in my custom class?
    y
    • 2
    • 5
  • v

    vkuznetsov

    11/08/2018, 3:28 PM
    it compiles just fine at playground
    a
    • 2
    • 1
  • m

    Massimo Carli

    11/08/2018, 3:29 PM
    I think the validate function should return
    String?
    🇳🇴 1
    a
    • 2
    • 3
  • a

    arekolek

    11/08/2018, 3:39 PM
    but in runtime it prints that result is null, that’s what I’m saying
    :thread-please: 1
    k
    • 2
    • 4
  • v

    vkuznetsov

    11/08/2018, 3:40 PM
    yes, in runtime it print's null despite function return type is String
    h
    • 2
    • 1
  • d

    dagguh

    11/08/2018, 3:58 PM
    Today we encountered
    Inheritance from an interface with ‘@JvmDefault’ members is only allowed with -Xjvm-default option
    I tried Googling and searching in this Slack, but came up short. I understand why the interface compilation needs this flag. But why do the implementations need this flag too? Can't the compiler see that the interface is compiled on JVM target 8 and uses the
    default
    Java 8 in the method and simply compile as if you implemented in Java? Here's a concrete incarnation of this problem: https://ecosystem.atlassian.net/browse/JPERF-260
    🤔 1
    m
    r
    • 3
    • 3
  • i

    igor.wojda

    11/08/2018, 5:47 PM
    Can somebody give me good example of using
    CharSequence.reduce
    function?
    d
    h
    +2
    • 5
    • 12
  • m

    marcelo

    11/08/2018, 7:47 PM
    When trying to do a
    File.copyTo
    and setting
    overwrite = true
    it still throws a
    FileAlreadyExistsException
    . I check the file permissions and so far can't write nor can't read. Is there anything that I can do to force a file to be updated? I tried deleting but nope.
    d
    • 2
    • 1
  • j

    jlleitschuh

    11/08/2018, 10:01 PM
    The Kotlin compiler is blowing up with an unusual exception if I try to compile a file with a ~2300 multi-line pretty printed JSON string. Is there a known limitation on the max number of lines that a multi-line string supports in Kotlin? Update: Trying to cut (cmd-x) this string out of IntelliJ has caused intelliJ to hang. Update: The hang is reproducible after restart of IJ. I might report this issue privately in youtrack, if that's possible.
    d
    • 2
    • 1
  • c

    camkadev

    11/09/2018, 10:08 AM
    kotlin bug?
    b
    e
    +2
    • 5
    • 13
  • b

    BillKarv

    11/09/2018, 10:12 AM
    Hi I am testing coroutines. I want my code to run in parallel, not waiting for a result. How am I suppose to do that? I 've searched the internet with no luck..
    b
    c
    • 3
    • 5
  • j

    jmfayard

    11/09/2018, 11:03 AM
    Which kotlin equivalent exist to make our terminals more lively like this? https://dev.to/ryanwhocodes/artii-lolcat-colorls-catpix-and-other-ruby-gems-to-add-color-to-your-terminal-572g
    m
    n
    j
    • 4
    • 5
  • i

    igor.wojda

    11/09/2018, 11:54 AM
    I want to make sublist that contains last element of my original list, however
    list.subList()
    2nd param
    toIndex
    is not end inclusive 🤔
    //have
    val list = listOf(1,2,3,4)
    
    //want sublist
    listOf(3,4)
    g
    a
    +2
    • 5
    • 6
  • d

    dalexander

    11/09/2018, 3:54 PM
    I’m running in to an interesting issue with generics and nested classes. For some reason changing the type parameter’s variance to in/out from invariant changes the visibility of a property using that type parameter.
    -.txt
    c
    i
    • 3
    • 6
  • c

    coder82

    11/09/2018, 5:19 PM
    With kotlin 1.3.0 it looks like a jvm subproject cannot depende anymore on a js subproject
    n
    • 2
    • 1
  • c

    coder82

    11/09/2018, 5:21 PM
    mmm it was nice to depend my backend jvm on the frontend js
    😱 1
    😞 1
    g
    • 2
    • 3
  • c

    coder82

    11/09/2018, 6:05 PM
    it used to work perfectly, the output.jar from the frontend contains a bunch of transpiled .js and web resources
    k
    • 2
    • 2
  • i

    igor.wojda

    11/09/2018, 6:45 PM
    I have general question about regular expressions In Javascript we can do this
    const matches = str.match(/[aei]/gi)
    to check if string contains
    a
    ,
    e
    or
    i
    character. However In kotlin this does not work. I wonder are the regular expression general cross-language concept or each language has own implementation (similar to other languages yet different)?
    h
    b
    +2
    • 5
    • 8
  • j

    jeggy

    11/09/2018, 6:53 PM
    How can I achieve something like this without using
    out
    ?
    k
    d
    • 3
    • 4
  • a

    Alowaniak

    11/09/2018, 7:36 PM
    how can I easily get a (sorted) frequency map of a LongArray? is there something neater than
    longArray.toList().groupingBy{ it }.eachCountTo(sortedMapOf())
    ?
    i
    • 2
    • 1
  • m

    Marcel Overdijk

    11/09/2018, 9:11 PM
    What are people using for checkstyle style/lint, findbugs for Kotlin (using Gradle build tool chain)?
    m
    n
    g
    • 4
    • 4
  • d

    dharrigan

    11/09/2018, 9:26 PM
    Oh dear, I think I've found a nasty bug in Kotlin 1.3, with ArraysJvm...https://youtrack.jetbrains.net/issue/KT-28113. Anyone else notice this?
    :kotlin: 1
    o
    • 2
    • 1
  • k

    kevinherron

    11/10/2018, 12:17 AM
    is there a Kotlin book that covers 1.2, or one coming that will cover 1.3 + coroutines?
    n
    i
    • 3
    • 4
  • c

    chansek

    11/10/2018, 11:38 AM
    I am correct in understanding how anonymous functions works in Kotlin?
    i
    • 2
    • 5
  • b

    Bernhard

    11/10/2018, 4:15 PM
    does kotlin support anon union types (e.g. String | Int)
    👍 1
    b
    i
    +2
    • 5
    • 14
Powered by Linen
Title
b

Bernhard

11/10/2018, 4:15 PM
does kotlin support anon union types (e.g. String | Int)
👍 1
b

Birneee

11/10/2018, 4:21 PM
No currently not But I think it would be a great addition to the type system
i

igor.wojda

11/10/2018, 4:26 PM
I am not so sure. In general I have seen only one useful example for union types and Kotlin. Can you provide few examples where union types would provide value?
👍 1
b

Bernhard

11/10/2018, 4:26 PM
mostly when compiling down to javascript
you have to deal with functions that can return different types
example: return object on success or false on failure, which certainly is bad practice but nonetheless cases like this exist in js
e.g. https://www.npmjs.com/package/@types/screenfull
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/screenfull/index.d.ts#L9
in Kotlin you probably would have to wrap these two types in a sealed class
👍 1
sealed class ScreenfullType { class Actual(val obj: ScreenFull); class DoesNotExist}
I suppose
i

igor.wojda

11/10/2018, 4:36 PM
Honestly I don’t see a point of pouting the core language only because one of the targets had bad architecture. These ScreenFull classes seems to be doing correct thing by abstracting bad code 🤔 BTW For JS as a target you could also use
dynamic
type (I know it’s far from perfect) https://kotlinlang.org/docs/reference/dynamic-type.html
b

Bernhard

11/10/2018, 4:39 PM
right, that's the first use case that comes to my mind
t

thanksforallthefish

11/10/2018, 4:39 PM
have fun reading (rabbit hole): https://youtrack.jetbrains.com/issue/KT-13108 but it does not seem unions will land anytime soon
👍 1
h

Hamza

11/10/2018, 10:00 PM
Just have Any refference and a variable for keeping info of what type the object is
View count: 1