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
getting-started
  • f

    forcelain

    03/04/2018, 1:38 PM
    I have a data class
    data class Item(
            val children: List<Item>
    }
    is there a way to make a deep (recursive) copy of such an object?
    item.copy()
    creates a copy of the top object only but not the
    children
    a
    k
    +2
    • 5
    • 13
  • s

    sourabhv

    03/05/2018, 1:08 PM
    So AndroidStudio is not suggesting anything. Great.
    l
    • 2
    • 1
  • s

    sourabhv

    03/05/2018, 1:11 PM
    And I get a warning to downgrade to
    1.2.21
    🤷‍♂️ 1
    l
    • 2
    • 1
  • d

    dierre

    03/06/2018, 9:23 AM
    Hello, I found an annoying behaviour here (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/first.html), if the array is empty it is thrown a
    NoSuchElementException
    . I found that I can obtain what I want using filter and then checking against list size. I was expecting to return a `T?`(meaning an optional of some kind) instead of
    T
    . So basically instead of doing
    list.first({p -> predicate}).orElse(defaultObject)
    I have to do something like
    var result = list.filter({p -> predicate}); if(result.isEmpty()) return defaultObject else result.first()
    . Do you think there is a better approach?
    s
    • 2
    • 3
  • a

    am

    03/06/2018, 1:38 PM
    Hello guys, Can any one please answer the following question https://discuss.kotlinlang.org/t/how-does-tolist-function-works/6905 🙏
    ➕ 1
    m
    a
    • 3
    • 7
  • g

    Giulio

    03/11/2018, 12:06 AM
    Hi! Can someone help me with this? Is there a simple method to transform the following
    responseBody =  myTask.get();
    into an async callback?
    d
    • 2
    • 4
  • t

    Tarun

    03/13/2018, 11:01 AM
    Hey Should we use annotations(Like @NonNull or @Nullable) with function arguments in kotlin to specify if function arguments are NonNull(Asking because of Null type handling in Kotlin being different) For Example
    fun callApi(@NonNull context: Context) : String{
            return "hello world!"
        }
    a
    • 2
    • 4
  • c

    cody.stringham

    03/13/2018, 2:56 PM
    Hey all, web developer here looking to learn me some kotlin for greater good. Does anyone have a recommendation for a framework to get started with? I've been pointed to https://javalin.io/ but wanted to ask the pros - also worth mentioning I have absolutely no java background.
    t
    • 2
    • 2
  • r

    Regan Russell

    03/13/2018, 9:39 PM
    why can I not have an enum class inside an inner class..??
    m
    e
    • 3
    • 2
  • p

    poohbar

    03/15/2018, 2:30 PM
    I would disagree with Kaidan here and maybe many others. I think Kotlin is not a good language to learn unless you have a decent understanding of Java. It really makes perfect sense if you know Java and liked Effective Java but some parts of the language make very little sense if taken out of context (of Java).
    👍 7
    j
    n
    • 3
    • 10
  • o

    oday

    03/16/2018, 9:50 AM
    what could possibly cause a filter operation not to be run? I mean the list is there and it gets successfully sorted by name through a comparator I have set
    a
    e
    • 3
    • 30
  • b

    bartek.t

    03/16/2018, 9:57 AM
    Is @Parcelize stable at the moment?
    m
    p
    • 3
    • 5
  • c

    chi

    03/19/2018, 6:43 AM
    Yeah @Shawn I'm just saying that, since there's the IDE feature with a language Kotlin is interoperable with (Java), why isn't it with Swift on intellij
    a
    • 2
    • 4
  • s

    Sobri

    03/19/2018, 6:57 AM
    is kotlin native just an experimental or will it be ready for production?
    a
    i
    • 3
    • 2
  • j

    jchannon

    03/19/2018, 2:36 PM
    Anyone used http://www.functionalkotlin.com/ ?
    a
    • 2
    • 1
  • a

    Andreas Sinz

    03/20/2018, 8:42 PM
    @diego-gomez-olvera https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems
    d
    • 2
    • 1
  • e

    edwardwongtl

    03/21/2018, 5:28 AM
    Oh then you can go to #rx
    k
    • 2
    • 1
  • t

    Thanos Psaridis

    03/21/2018, 12:00 PM
    Hello guys Kotlin noob here. I have declared some top level functions inside
    Utils.kt
    file which I'm calling them in another class but how can someone else find out that those functions reside in the
    Utils.kt
    file just by reading at my code? If you ctrl+click on function IntelliJ takes me to the
    Utils.kt
    file but how can I do that without the help of the ide?
    h
    s
    • 3
    • 10
  • m

    mbickel

    03/21/2018, 4:47 PM
    Doesn't look awfully optimized for memory, but my applications only do trivial amounts of values in each dimension.
    k
    • 2
    • 1
  • a

    alexandretaz

    03/21/2018, 7:26 PM
    Guys I'm writing an app to my son's cell send me his location every minute I searched that I can do it using foreground service is there any tutorial explaining how to do that with Kotlin
    k
    a
    • 3
    • 2
  • a

    alexandretaz

    03/22/2018, 6:12 PM
    Hello i'm creating a system that shoud create a service when the user open the main activity, this service configure a timer so every 10 seconds hi sends a a post to a http server. Even if it's on bg
    r
    • 2
    • 4
  • j

    jchannon

    03/22/2018, 10:58 PM
    Are there any projects aimed at teaching kids Kotlin?
    k
    • 2
    • 1
  • s

    sandeep

    03/23/2018, 5:04 AM
    /** Property */
        PROPERTY,
        /** Field, including property's backing field */
        FIELD,
    k
    • 2
    • 1
  • z

    zpearce

    03/23/2018, 9:11 PM
    I have a java class with a bunch of static methods on it. Is there a way to use kotlin's
    with()
    against that?
    with(MyJavaType) {}
    complains about MyJavaType not having a companion object.
    k
    • 2
    • 1
  • k

    kristofdho

    03/24/2018, 12:40 AM
    so give it a regex
    it.matches(Regex("\.[abc]\."))
    👍 2
    n
    b
    • 3
    • 3
  • b

    benleggiero

    03/24/2018, 2:15 AM
    So… what are the
    _main
    modules? They aren’t mentioned on https://kotlinlang.org/docs/reference/multiplatform.html

    https://i.imgur.com/s0HnpUk.png▾

    i
    • 2
    • 4
  • p

    pal0810

    03/25/2018, 1:39 PM
    can anyone recommend me a fast track course for android using kotlin. ps: wanna build an online laundry platform
    a
    • 2
    • 1
  • s

    sarna

    03/26/2018, 5:21 PM
    alright, I'll try to find something 👍 thanks
    s
    d
    • 3
    • 22
  • o

    oday

    03/29/2018, 6:42 AM
    I’m using Codacy for code quality, I get this message about my injection code http://snpy.in/rsWGMm
    s
    • 2
    • 3
  • g

    Gerard Klijs

    03/29/2018, 10:37 AM
    I’m calling some clojure from kotlin, would it be idiomatic to put it all in a spring component, and use that fro the interactions? This way I have the non-type-safe stuff all in one place, other code can use the ‘typesafe’ functions from the component?
    n
    • 2
    • 3
Powered by Linen
Title
g

Gerard Klijs

03/29/2018, 10:37 AM
I’m calling some clojure from kotlin, would it be idiomatic to put it all in a spring component, and use that fro the interactions? This way I have the non-type-safe stuff all in one place, other code can use the ‘typesafe’ functions from the component?
n

nfrankel

03/29/2018, 11:01 AM
no experience but that would be interesting perhaps when it works, you would be able to write a blog post about it?
g

Gerard Klijs

03/29/2018, 11:06 AM
I probably could, but for now I just try to build a little thing in Kotlin from clojure, also using avro and postgress, with some data types like UUID. It’s for an internal workshop about event sourcing.
👍 1
n

nfrankel

03/29/2018, 11:08 AM
have fun!
View count: 2