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

    Chris Cunningham

    11/12/2018, 12:04 AM
    is equality for maps just checking the object reference, or is it seeing if they contain the same data
    k
    i
    • 3
    • 6
  • s

    Shawn

    11/12/2018, 4:04 PM
    If you need instances, that sounds more like sealed classes than enums
    n
    k
    • 3
    • 7
  • j

    Jukka Siivonen

    11/13/2018, 7:59 AM
    can someone explain or point documentation what is the reasoning behind that using return in list.map { return xxx } is not actually return of value of the lambda function? and what is the use case where this return behavior would be useful?
    e
    a
    e
    • 4
    • 10
  • r

    Ruckus

    11/13/2018, 4:59 PM
    Assign it to a local val first
    s
    p
    s
    • 4
    • 10
  • d

    dG

    11/14/2018, 1:08 PM
    beautiful. Thanks!
    s
    • 2
    • 2
  • s

    Sergey Shnifer

    11/15/2018, 9:31 AM
    what is the Kotlinish way to solve this?
    n
    • 2
    • 1
  • s

    Sergey Shnifer

    11/15/2018, 9:41 AM
    well, i used
    <http://handler.post|handler.post>(object: Runnable{
            ...
            })
    and this works. Thanks a lot!
    👎 1
    👍 1
    o
    s
    r
    • 4
    • 7
  • c

    CodeRed

    11/16/2018, 3:42 PM
    Hi there fellas, I'm currently experimenting on kotlins standard lib functions, especially on use(). Unfortunately I'm still not sure how it works in case of an Exception being thrown. I have this function that writes a File to my apps storage:
    fun writeSoundToSharedStorage(context: Context, sound: ISound): Boolean {
    
            var inputStream: InputStream? = null
            var outputStream: OutputStream? = null
            val targetFile = getTargetFileFromSoundName(sound.soundName()) ?: return false
    
            try {
    
                inputStream = context.assets.open(getAssetPathFromSound(sound))
                outputStream = FileOutputStream(targetFile)
                inputStream.copyTo(outputStream)
            } catch (ex: IOException) {
                Log.e(LOG_TAG, "Failed to save file: ${ex.message}")
                return false
            } finally {
                try {
                    inputStream?.close()
                    outputStream?.close()
                } catch (ex: IOException) {
                    ex.printStackTrace()
                }
            }
            return true
        }
    What I'm thinking about is to migrate the try-catch-finally-block to a use()-block. But from the docs of use() I'm not sure if exceptions are handled or not. I took a look into the implementation and for me it looks like an exception is thrown, so my guess would be that my app would crash as long as I don't handle it somehow. Also my function depends on returning false if something went wrong. It would be nice if someone could bring some more clarity to me 🙂
    d
    m
    r
    • 4
    • 12
  • d

    dimkoss11

    11/16/2018, 6:15 PM
    Hello all
    class MapBuilder<T,U> {
        operator fun invoke(arg: T): MapBuilder<T, U> {
            return this
        }
        operator fun invoke(arg: U): MapBuilder<T, U> {
            return this
        }
    }
    of course it's don't work due to JVM limitations. Platform declaration clash: The following declarations have the same JVM signature
    (invoke(Ljava/lang/Object;)Lcom/test/tests/MapBuilder;):
        operator fun invoke(arg: T): MapBuilder<T, U> defined in com.test.tests.MapBuilder
        operator fun invoke(arg: U): MapBuilder<T, U> defined in com.test.tests.MapBuilder
    Any ideas how can I realize this?
    b
    i
    a
    • 4
    • 5
  • k

    karelpeeters

    11/16/2018, 6:17 PM
    What if I have a
    MapBuilder<String, String>
    ?
    d
    n
    a
    • 4
    • 8
  • g

    gabin

    11/16/2018, 7:35 PM
    Hello. I’m new to Kotlin. I’ve created an empty Kotlin project from this instruction https://kotlinlang.org/docs/tutorials/getting-started.html , but I don’t have run button in Project. Could you give me an advice
    a
    • 2
    • 1
  • g

    gabin

    11/16/2018, 7:36 PM
    p
    • 2
    • 1
  • g

    gabin

    11/16/2018, 7:39 PM
    thanks, it works now. Can I add coroutines library easily? In empty project I don’t see gradle files
    k
    a
    • 3
    • 3
  • k

    karelpeeters

    11/16/2018, 9:19 PM
    Does building with gradle work?
    g
    • 2
    • 3
  • s

    Slava Glushenkov

    11/17/2018, 7:57 AM
    -.kt
    k
    i
    • 3
    • 2
  • g

    gabin

    11/17/2018, 2:09 PM
    Hello guys, what does it mean? “‘get(String, HttpRequestBuilder.() -> Unit = ...): T’ is deprecated. Experimental coroutines support will be dropped in 1.4” . I’m using ktor framework + coroutines and ktor methods are highlighted as deprecated
    r
    • 2
    • 2
  • p

    Pat

    11/17/2018, 5:44 PM
    I can't get Kotlin to run on a fresh project with IDEA. When I mark /src as Sources Root, I get the message "Kotlin not configured" above the file. No idea whats going wrong
    m
    • 2
    • 4
  • c

    Chris Cunningham

    11/17/2018, 8:08 PM
    is it pretty common for people to have there own mutable types for private use in a system, then having a immutable version of the same type for exposing that object publicly?
    s
    s
    • 3
    • 4
  • g

    gabin

    11/17/2018, 9:15 PM
    Can someone advice kotlin library for parsing html? Desirably multiplatform kotlin library
    n
    • 2
    • 2
  • a

    aarjav

    11/17/2018, 11:10 PM
    What does it mean if there is a lambda with a nullable receiver?
    this
    can == null in the body of the lambda?
    fun foo(block: String?.() -> Unit)
    vs
    fun foo(block: String.() -> Unit)
    I noticed that with the second I cannot call
    .block()
    on a
    String?
    but the lambda body (for block param where foo is used) stays the same.
    r
    • 2
    • 2
  • a

    alex

    11/18/2018, 11:21 AM
    Does it (::update) produce new lambda on each invocation like in Java or it's cached somewhere?
    e
    i
    • 3
    • 2
  • v

    ValV

    11/18/2018, 12:56 PM
    Well, I have also vim-plugin, so it's an extra problem to find shortcut (trial and error) + window manager grabs all
    Cmd+...
    shortcuts
    m
    • 2
    • 6
  • g

    gabin

    11/19/2018, 11:56 AM
    Sorry for stupid question - how to get the size of sequence? I’ve looked through the whole doc and can’t find https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/-sequence/index.html
    j
    • 2
    • 3
  • j

    jurajsolarml

    11/19/2018, 1:19 PM
    Hello, I'm a beginner. Please help. Where can be a bug? Thank you
    h
    r
    m
    • 4
    • 11
  • j

    jurajsolarml

    11/19/2018, 1:19 PM
    a
    • 2
    • 4
  • g

    gabin

    11/19/2018, 1:48 PM
    is there method in kotlin that allows to unescape html chars? E.g convert &#039; -> ' , &#038; as &(ampersand), &#037; as % and so on
    o
    • 2
    • 2
  • c

    ClaudiuB

    11/19/2018, 2:33 PM
    I'm planning on making a Kotlin library for core Android logic of apps. Is there a gradle plugin/distribution playtform any of you can recommend?
    o
    a
    a
    • 4
    • 5
  • o

    oshai

    11/20/2018, 5:22 PM
    Hi, I have a styling question related to data classes and copy method.
    val connectionUri = "jdbc:postgresql://$host:$port/$database?user=$username&password=$password"
    
    val connection = PostgreSQLConnectionBuilder.createConnectionPool(connectionUri) { it.copy(
            connectionCreateTimeout = 1
    )}
    I am writing a lib and I want to configure a connection. Configuration is a data class and all are vals. Can I avoid the
    it.copy
    in the code above (call the copy somehow in the lib), or is there an apply method?
    d
    n
    +2
    • 5
    • 26
  • m

    Mark

    11/21/2018, 4:42 AM
    Should we use
    hashSetOf<X>()
    or
    HashSet<X>()
    for when we want a mutable hash set?
    r
    • 2
    • 1
  • j

    Jieyi

    11/21/2018, 4:49 AM
    Hello, I upgraded from version 5.3.0 to 6.0.0. Inside of
    implement org.kodein.di:kodein-di-generic-jvm:6.0.0
    this library, there's no
    kodein-di-core-common
    and
    kodein-di-core-jvm
    library. Did I miss somethin?
    r
    o
    • 3
    • 4
Powered by Linen
Title
j

Jieyi

11/21/2018, 4:49 AM
Hello, I upgraded from version 5.3.0 to 6.0.0. Inside of
implement org.kodein.di:kodein-di-generic-jvm:6.0.0
this library, there's no
kodein-di-core-common
and
kodein-di-core-jvm
library. Did I miss somethin?
6.0.0 miss this library.
r

rnpy

11/21/2018, 5:42 AM
might have more answers in #kodein
o

Oleg Yukhnevich

11/21/2018, 7:09 AM
you need kodein-di-core and kodein-di-core-jvm for common and jvm impl
plus erased or generic
View count: 2