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

    poohbar

    08/03/2018, 6:25 PM
    Is there anyway I could get:
    CompletableFuture<List<Person>>
    from
    List<CompletableFuture<Person>>
    I can't wrap my head around it 😕
    :stackoverflow: 1
    r
    d
    +2
    • 5
    • 6
  • s

    Shawn

    08/03/2018, 9:27 PM
    you will need a while loop if a continue is not sufficient 😛
    b
    • 2
    • 4
  • k

    kevin.cianfarini

    08/04/2018, 3:07 AM
    Also,
    api.getArtists()
    is a suspending function itself so I haven't quite figured out how to overcome that yet since
    buildIterator
    is not a suspending context
    d
    • 2
    • 6
  • a

    adam-mcneilly

    08/05/2018, 4:02 PM
    I'm making a Kotlin cheatsheet for https://devhints.io and I'd appreciate any feedback you have. It doesn't have everything yet and I'm aware of that, but if you feel like something glaring is missing leave a comment on the PR. Thanks! 🙂 https://github.com/rstacruz/cheatsheets/pull/724
    👍 1
    s
    a
    • 3
    • 8
  • m

    Mahdi Javaheri

    08/06/2018, 6:57 AM
    Hi i'm an android developer used to write my codes with Java i wanna learn Kotlin but im confused which resources are good to start anyone can help me?
    k
    • 2
    • 3
  • t

    Todor Atanasov

    08/06/2018, 7:32 AM
    Hi guys, I am trying to build dsl for tests that are currently written in Java and just rewrite them. When doing so I tried to run one test but it doesn't @Autowire some stuff in one of the java classes that I use. Other than adding kotlin to the dependencies of the project should I add something else or is it fixed in other way? 🙂 Sorry if it is not the right place to ask.
    g
    • 2
    • 2
  • c

    Can Orhan

    08/06/2018, 2:08 PM
    Is there a way to construct a sealed class with referenced children? Something like
    sealed class Seal {
        class InnerClass: Seal()
        ReferencedClass::class
    }
    k
    • 2
    • 9
  • s

    Siva

    08/06/2018, 2:16 PM
    hi folks, Kotlin having any memory profiler like visualvm ? preferrably opensource
    c
    c
    k
    • 4
    • 7
  • d

    deinspanjer

    08/06/2018, 2:17 PM
    Hi folks, I could really use some help. I’m trying to take a template Kotlin / Spring Boot application and get it running with some real data. In order to do so, I need some way to wire in a path to a directory. I don’t care if it is a command line argument or a property read by Spring, but I can’t find a way to get either to work properly. 😕 right now, I’m trying the prop method, so I have
    @Configuration @ConfigurationProperties class AppProps { @NotNull lateinit var sourceRoot: String}
    and later on, inside a component class:
    @Component class Platform(..., appProps: AppProps) { init { val sourceRoot = appProps.sourceRoot } }
    but when I try to print that val, it is empty.
    k
    • 2
    • 1
  • a

    Aregev2

    08/06/2018, 4:13 PM
    How can I convert a list with 4 elements:
    mutableListOf(a, b, c, d)
    to a map when
    {a=b, c=d}
    ?
    • 1
    • 1
  • a

    Aregev2

    08/06/2018, 4:15 PM
    I dont think so
    s
    a
    r
    • 4
    • 6
  • k

    karelpeeters

    08/06/2018, 4:29 PM
    .chunked(2)
    works too.
    👏 1
    🤯 4
    s
    a
    a
    • 4
    • 11
  • c

    cored

    08/06/2018, 4:32 PM
    are companies really jumping into koitlin for development without going into mobile things?
    :yes: 6
    a
    j
    +3
    • 6
    • 9
  • a

    Aregev2

    08/06/2018, 4:51 PM
    Hi, I got this piece of code:
    val nested = listOf(listOf(12), listOf(12))
        val (one, two) = nested
        println("$one, $two")
    That throws IOFB exception, I do not understand why
    r
    s
    +2
    • 5
    • 15
  • a

    Aregev2

    08/06/2018, 5:27 PM
    What is the difference between
    isEmpty()
    and
    none()
    ?
    s
    a
    +3
    • 6
    • 19
  • e

    elye

    08/07/2018, 6:42 AM
    Anyone want to put in your recommendation as per this stackoverflow? https://stackoverflow.com/questions/51718229/kotlin-val-mutablelist-vs-var-immutablelist-when-to-use-which
    h
    • 2
    • 5
  • m

    marschwar

    08/08/2018, 2:49 PM
    Hi, after trying for several hours, I could really use some help.
    sealed class MyTypes
    
    class A : MyTypes()
    class B : MyTypes()
    
    class Wrapper<out T : MyTypes>(val wrapped: T)
    
    val wrappedValue: Wrapper<MyTypes> = Wrapper(A())
    
    val nothing = when (wrappedValue.wrapped) {
        is A -> doSomethingWithA(wrappedValue as Wrapper<A>)
        is B -> doSomethingWithB(wrappedValue as Wrapper<B>)
    }
    
    fun doSomethingWithA(a: Wrapper<A>) = Unit
    fun doSomethingWithB(b: Wrapper<B>) = Unit
    Is there any way I can get rid of the unchecked cast within the
    when
    ?
    u
    c
    • 3
    • 5
  • n

    nfrankel

    08/08/2018, 4:40 PM
    by jetbrains? 😉
    🇳🇴 2
    :no_red: 2
    :yes: 3
    o
    • 2
    • 2
  • b

    bdawg.io

    08/08/2018, 5:10 PM
    Does KDoc have any syntax support for providing URL links?
    c
    k
    a
    • 4
    • 9
  • b

    Bernhard

    08/09/2018, 6:24 AM
    are collections completely immutable by default if you use val?
    r
    a
    • 3
    • 11
  • j

    jk2018

    08/09/2018, 9:52 AM
    Is there something like "explicit interface implementation" ( like in C# , see https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/interfaces/explicit-interface-implementation ) ?
    a
    • 2
    • 6
  • k

    Konstantin Petrukhnov

    08/10/2018, 12:53 PM
    MutableMap.toMap() return mutableMap if size >1. How I should get immutable map from mutable map?
    🤔 1
    a
    a
    • 3
    • 5
  • p

    poohbar

    08/10/2018, 1:40 PM
    I have this simple class composition:
    data class Account(a: Int, b: Int)
    data class Person(name:String, account:Account)
    is there a way to expose account's properties on person? anything better than:
    val a get() = account.a
    ?
    a
    • 2
    • 1
  • r

    rakeeb

    08/11/2018, 1:07 AM
    is it possible to have a generic operator overload?
    s
    • 2
    • 3
  • t

    tateisu

    08/12/2018, 11:40 PM
    Is Kotlin's singleton thread-safe?
    d
    a
    k
    • 4
    • 6
  • g

    gabrielfv

    08/14/2018, 4:35 PM
    Has anyone seen something like
    val foo = bar ?: null.also { /* do something only when null */ }
    o
    • 2
    • 3
  • a

    Ayden

    08/15/2018, 12:24 PM
    If I don't have the fundamental or knowledge about Java. Can I start to learn Kotlin directly?
    k
    d
    s
    • 4
    • 9
  • m

    Mohamed Ebrahim

    08/16/2018, 3:52 AM
    simple "Hello world" program give me Error :
    k
    • 2
    • 2
  • s

    Slackbot

    08/16/2018, 5:56 PM
    This message was deleted.
    a
    k
    • 3
    • 2
  • p

    poohbar

    08/16/2018, 7:38 PM
    yup, immutable data classes are sweet, especially with kotlin's named arguments but they become pain in the a** when using from java where you cant easily use
    copy()
    😞
    a
    • 2
    • 1
Powered by Linen
Title
p

poohbar

08/16/2018, 7:38 PM
yup, immutable data classes are sweet, especially with kotlin's named arguments but they become pain in the a** when using from java where you cant easily use
copy()
😞
a

Andreas Sinz

08/16/2018, 7:45 PM
You could create your own version:
class Person(val name: String) {
    val updated = Instant.now()

    @JvmOverloads
    fun copy(name: String = this.name) = Person(name)
}
View count: 1