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

    06/01/2018, 10:44 AM
    So it's not like there is a single integer for the recursion limit, it'll depend on how much space a stack frame takes up for your particular function.
    w
    • 2
    • 1
  • w

    warriorprincess

    06/01/2018, 11:00 AM
    does
    minBy
    actually give a reference to original object? I do
    lowest = lowest?.next
    in my code above, does it actually move the
    head
    of the list stored in
    lists
    ?
    d
    • 2
    • 50
  • a

    aandreyev

    06/01/2018, 12:21 PM
    Hello I am trying to use micronaut but cannot debug tests in IDEA Seems like the issue is related to kapt annotation processing. https://stackoverflow.com/questions/50642455/kotlin-micronaut-testng-test-fails-in-idea-but-pass-via-gradle Is there any config trick or workaround?
    e
    • 2
    • 6
  • f

    Fuyang

    06/01/2018, 1:23 PM
    Maybe someone here can help me with this how to stop
    null
    get into map values from json string? https://stackoverflow.com/questions/50643864/kotlin-how-to-prevent-null-gets-into-map-object-during-jackson-json-deserializ Much appreciated 🙂
    c
    • 2
    • 1
  • s

    selva

    06/01/2018, 2:31 PM
    Hi Friends, I am upgrading kotlin from 0.9.223 to 1.2.31. After upgrade i am getting an error since kotlin-time split into stdlib and stdlib-js. There is shared code used in JVM and JS modules. But having problem with compiling Date dataype. Since kotlin.js.Date works JS module and java.util.Date works in JVM module. can anyone please help me on this ? Thanks Selva
    k
    • 2
    • 1
  • w

    warriorprincess

    06/01/2018, 7:27 PM
    fun mergeKLists(lists: Array<ListNode?>): ListNode? {
            var holder: List<ListNode?> = arrayListOf()
            while (true) {
                val bulk = lists.withIndex().minBy { (_, value) -> value?.`val` ?: Int.MAX_VALUE }
                val index = bulk?.component1(); val lowest = bulk?.component2() ?: break
                holder += lowest
                lists[index!!] = lists[index]?.next
            }
            for (index in 1 until holder.size) holder[index-1]?.next = holder[index]
            return if (holder.isNotEmpty()) holder[0] else null
        }
    c
    i
    • 3
    • 16
  • w

    warriorprincess

    06/01/2018, 7:28 PM
    guys any comments on code quality and style? Am I using any kotlin features in a way not recommended?
    a
    • 2
    • 3
  • r

    Roman Dzhadan

    06/02/2018, 9:30 AM
    Hey guys! I'm trying to upgrade my microservices up to JVM 10. Latest maven plugin says:
    org.jetbrains.kotlin:kotlin-maven-plugin:1.2.41
    >>
    Unknown JVM target version: 10. Supported versions: 1.6, 1.8
    Is there any chance to run JVM 10 with Kotlin 1.2?
    n
    • 2
    • 3
  • k

    kenkyee

    06/02/2018, 9:40 AM
    Change your jvm so it targets java 1.8 byte code...
    r
    • 2
    • 1
  • h

    Hamza

    06/02/2018, 10:42 AM
    No channel for javalin? 🤔
    c
    • 2
    • 1
  • k

    karelpeeters

    06/02/2018, 2:06 PM
    Someone did a while ago:
    #33244c,#423393,#944c94,#FFFFFF,#423393,#FFFFFF,#944C94,#F88909
    s
    u
    n
    • 4
    • 5
  • t

    thomasnield

    06/02/2018, 6:18 PM
    Stack overflows aside, my question is this: can recursion inside a
    Sequence
    flatMap()
    be bad for performance when you need to recurse a larger number of items (e.g. 1000, 10000)? Should I be doing a loop with
    tailrecur
    instead?
    k
    • 2
    • 2
  • c

    coder82

    06/02/2018, 10:22 PM
    is there a coroutine primitive which waits for a flag to be set?
    k
    • 2
    • 1
  • m

    mik_os

    06/03/2018, 7:25 PM
    Hi, I have a question about Kotlin compiler performance. My project (Android app) have next stats:
    -------------------
    Language       code
    -------------------
    Java          42659
    Kotlin         8834
    Task
    compile<Flavor>Kotlin
    takes 25s Task
    compile<Flavor>JavaWithJavac
    takes 8s Is this something I should report to bugtracker? Or 14x (3x more time for 4.6x less code) slower kotlin compilation have some reasonable explanation?
  • t

    tschuchort

    06/03/2018, 8:58 PM
    is there any way to get a reference to a property? I can do this:
    fun <T> foo(t: T, setProp: T.(Int) -> Unit, getProp: T.() -> Int) = t.apply { setProp(getProp() + 1) }
    but what I want to do is:
    fun <T> foo(t: T, prop: Property<T,Int>) = t.apply { prop += 1 }
    d
    • 2
    • 13
  • l

    lawlorslaw

    06/04/2018, 8:40 AM
    The
    kotlin-koans
    repo is the problem. Every time you make a change to a test you have to rerun the
    testClasses
    Gradle task.
    a
    • 2
    • 2
  • k

    karelpeeters

    06/04/2018, 9:00 AM
    (with large constant factors because all of the lists beging created)
    w
    • 2
    • 6
  • b

    Benoit Duffez

    06/04/2018, 11:41 AM
    Hello. I have a class (let's call it
    Entity
    ) that is inherited from two children, and they need to change the type of one property. This is because these classes are used to retrieve data from a backend (in serialized in JSON, deserialized with Gson). In fact, the server uses the same object for downlink (e.g.
    GET /x/y/z.json
    returns a list of
    Entity
    ) and uplink (
    POST /abc
    with one
    Entity
    in the body), but one of the fields has not the same type whether it's uplink or downlink (bummer... I can't change the server code...). So in
    Entity
    i have declared the property as
    open var stuff: Any? = null
    , and I expected the
    EntityUplink
    for example to have
    override var stuff: ActualType? = null
    but the compiler refuses that. Is that a violation of the language (e.g. not possible/not designed to do that) or am I missing something?
    h
    • 2
    • 5
  • b

    BorzdeG

    06/04/2018, 3:23 PM
    Prompt, how to receive in a method “getProperty” a field name?
    abstract class DemoSuper() {
      protected fun getProperty(defaultValue: String): String {
        // field name?
        return defaultValue
      }
    }
    
    class Demo : DemoSuper() {
      val f0: String by lazy { getProperty("f0") }
      val f1: String by lazy { getProperty("f1") }
    }
    d
    • 2
    • 2
  • k

    karelpeeters

    06/05/2018, 9:57 AM
    Sure,
    property.returnType
    .
    a
    • 2
    • 1
  • e

    edwardwongtl

    06/05/2018, 10:15 AM
    I think it more about compiler trick for this to work
    a
    • 2
    • 1
  • t

    tschuchort

    06/05/2018, 10:18 AM
    meanwhile you can use an epimorphism to lift any
    Killer -> A
    function to a
    Test -> A
    function but it's somewhat annoying to use
    b
    • 2
    • 7
  • n

    nwh

    06/05/2018, 1:14 PM
    Is there a way to hook into a data class' copy method? For example:
    data class Example(val name: String?)
    Let's say I have an
    Example("")
    , but I want blank strings to be null. I can do:
    ex.copy(name = if (name.isBlankOrNull()) null else name)
    But this requires hard coding. Is there a safe way to process all the fields like this?
    a
    • 2
    • 1
  • g

    gyl

    06/05/2018, 3:36 PM
    Hello everyone, Did someone managed to unit test
    object
    classes ? We would like, for each test, re init a
    lateinit var foo
    property with different values a on our singleton, but actually, once it is initialized once, we found no way to reinit the singleton. Sorry for my english..
    a
    g
    • 3
    • 4
  • b

    bdawg.io

    06/05/2018, 4:39 PM
    Is there a fundamental difference between
    IntArray
    and
    Array<Int>
    ? If so, is there a reason why the compiler doesn’t treat them as type aliases?
    d
    r
    • 3
    • 10
  • a

    adams2

    06/05/2018, 6:17 PM
    recommendations for avoiding an NPE on line 15?
    b
    • 2
    • 1
  • s

    Seri

    06/05/2018, 8:43 PM
    I love that font
    s
    k
    +4
    • 7
    • 14
  • j

    jmccance

    06/05/2018, 8:50 PM
    His take was “If I have an
    x
    and call
    copy
    on
    x
    , I expect to be able to call the same functions on the copy as I could on
    x
    .”
    a
    a
    m
    • 4
    • 16
  • d

    david-wg2

    06/06/2018, 8:44 AM
    anyone here have experience with bazel (https://bazel.build/)?
    g
    • 2
    • 1
  • a

    Andrei

    06/06/2018, 9:09 AM
    So it's a bad a idea to chain such deconstructive methods together?
    d
    g
    • 3
    • 5
Powered by Linen
Title
a

Andrei

06/06/2018, 9:09 AM
So it's a bad a idea to chain such deconstructive methods together?
d

diesieben07

06/06/2018, 9:47 AM
Can you please specifiy what you mean by "deconstructive"?
g

gildor

06/06/2018, 10:39 AM
If I understand you correctly, you talking about nesting of lambda with receiver. IMO it depends on case. I consider bad practice to nest lambda with default
it
param, but for lambda with receiver it’s sometimes not confusing and reasonable, but be careful name conflict
a

Andrei

06/06/2018, 11:26 AM
I was implying (T.() -> R) type of lambdas
as deconstructive, since no
it
inside them
g

gildor

06/06/2018, 12:23 PM
T.() Is lambda with receiver
View count: 2