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

    Jukka Siivonen

    01/18/2019, 1:12 PM
    How does IDEA support this? If I leave root directory out, where do I specify "base package" for new classes? Without something like this am I supposed to fix package name for newly created class every time?
    h
    c
    • 3
    • 10
  • h

    Hullaballoonatic

    01/18/2019, 9:40 PM
    is there a way to accomplish this without finding some class from which both inherit?
    s
    p
    • 3
    • 52
  • k

    karelpeeters

    01/18/2019, 10:38 PM
    Not that `final`s aren't even runtime constant, they can still be changed by reflection.
    s
    • 2
    • 4
  • h

    Hullaballoonatic

    01/18/2019, 10:59 PM
    why doesn't Java just make use of
    const
    ? they've had it reserved and unused for how long now?
    🤷 2
    s
    • 2
    • 2
  • h

    Hullaballoonatic

    01/19/2019, 11:42 PM
    can i control how various classes are cast to one of mine with
    as
    and
    is
    ? As in, I have made a custom class, and is somewhere else a cast some class to it with
    as
    , it would follow code i wrote somewhere else to do so. Does that make sense?
    a
    • 2
    • 1
  • u

    ursus

    01/20/2019, 4:17 AM
    for (lookupTask in lookupTasks) {
        val serverUrl = lookupTask.execute(domain, username, password)
        if (serverUrl != null) {
            return serverUrl
        }
    }
    return null
    p
    a
    • 3
    • 5
  • p

    popescustefanradu

    01/20/2019, 1:05 PM
    hey, I have a repository that returns a nullable object, how do i make a nice code that returns a field of that object if the object exists and otherwise does some other business?
    t
    a
    • 3
    • 5
  • b

    bjonnh

    01/21/2019, 3:51 AM
    I have a function like that: fun ConfigurationManager.getXConfig(): List<Resource> {} I would like to be able to do: fun ConfigurationManager.getXConfig(): XConfigs {} so I can write extension functions such as Xconfigs.names (that would be a simple fun XConfigs.names: get() = this.map { it: Resource -> it.name }
    s
    • 2
    • 1
  • h

    Hullaballoonatic

    01/21/2019, 5:34 AM
    i guess i should know this from java, but i always just make sure by programming around the question, and figured I'd finally ask:
    val data = aDataClassOrSomething(foo = ArrayList<Stuff>())
    val bar = data.foo
    is
    bar
    passed by reference or just value? If I alter
    bar
    does it alter
    data.foo
    ?
    s
    a
    • 3
    • 6
  • a

    Azhar

    01/22/2019, 11:02 AM
    #getting-started how to data class empty secondary constructor in kotlin
    a
    a
    • 3
    • 2
  • c

    CarlosBlanco

    01/22/2019, 3:03 PM
    how can i write code like @hudsonb? insade of square
    a
    • 2
    • 1
  • f

    febs

    01/22/2019, 9:07 PM
    Getting the hang of Collections. How do a List of Pairs and a Map differ in practical use, and when should I chose one over the other? I've noticed that I can create both pairs and maps with the "to" infix function: val listaOfPairs : List<Pair<String, Int>> = listOf( "ciao" to 2) val map: Map <String, Int> = mapOf( "ciao" to 2 ) Thanks 🤗 🤗
    s
    • 2
    • 1
  • r

    Ruckus

    01/22/2019, 9:10 PM
    A list of pairs is just a list of paired values. A map is a mapping from keys to values, so you can for example lookup values by keys. (Sorry to use the names in the descriptions, but in my defense, they are aptly named)
    val people = mapOf("a" to Person("Fred"), "b" to Person("George"))
    val fred = people["a"]
    s
    f
    +2
    • 5
    • 10
  • i

    ivano

    01/24/2019, 10:06 AM
    Communicate_between_two_fragments_via_interface.txt
    m
    • 2
    • 18
  • s

    Smorg

    01/24/2019, 1:31 PM
    Hi guys, I have a sealed class S in another class V with subtypes of the sealed class defined in it. How can I access methods of V in the subtypes?
    class V {
        fun doSomething() {
            ...
        }
    
       sealed class S {
             object S1: S() {
                 // how can I possibly do below:
                 init {
                      doSomething()
                 }
             }
       }
    }
    I know for a regular class, I just need to declare it as inner and call the regular outer class methods from it
    m
    • 2
    • 5
  • f

    febs

    01/25/2019, 12:36 PM
    I have this map: private val listOfFeeds : Map<String, String> If I try to access an element with val s = listOfFeeds[key] The return type of "s" is String? And not String. I guess that's because the compiler can't assume it'll get a value for that key. Right? And if so, how can I work around the problem? Is !! the only solution here?
    s
    d
    +3
    • 6
    • 6
  • p

    pugnator

    01/26/2019, 8:15 AM
    Hello! I have Webview and I need for it doubleClick for show and hidden menu
    :stackoverflow: 6
    :android: 2
    s
    • 2
    • 1
  • j

    jurajsolarml

    01/27/2019, 4:20 PM
    Hello,Please can you help me ? I am beginner. I'm not sure how to do it. /Kotlin/ Thanks
    d
    j
    • 3
    • 14
  • a

    aarjav

    01/28/2019, 12:09 AM
    How to go from
    Function<T,R>?
    to
    ((T) -> R)?
    I used an extension property
    val Function<T,R>.lambda: ((T) -> R) get() = this::apply
    and use it like
    func?.lambda
    v
    k
    • 3
    • 4
  • v

    voddan

    01/28/2019, 2:49 PM
    Hi! I've got a very weird problem with Gradle. Any help or tips will be greatly appreciated. https://stackoverflow.com/questions/54404400/test-fail-with-noclassdeffounderror-kotlin-autocloseablekt
    h
    i
    • 3
    • 3
  • i

    ivano

    01/29/2019, 10:58 AM
    why?
    m
    r
    • 3
    • 15
  • j

    Jay

    01/29/2019, 1:53 PM
    I keep trying to do
    return <whatever>
    from lambdas - I know I just need to remove the
    return
    , but can anyone explain the error message to me? From the expected type it looks as if the
    return
    from within the lambda is capable of terminating the enclosing function call - how is this possible? Would this pop the stack from the lambda, the
    partition
    call, and the enclosing function - like a
    throw
    ?
    s
    s
    • 3
    • 17
  • k

    Kevin

    01/30/2019, 2:00 AM
    Hi all! I’m trying to make an app that looks at my messages on my macbook. MacOS Mojave blocks access to the
    ~/Library/Messages
    folder by default. I have 2 questions: 1. How can I request permission to access this folder in Kotlin? 2. Can I give IntelliJ and all child processes permission to access this folder? I gave IntelliJ full disk access, but that doesn’t seem to give permissions to my app when I click the
    run
    button. Right now I have to build the whole app and manually add that build to my security settings each time.
    n
    a
    • 3
    • 3
  • a

    Anton Lakotka [JB]

    01/30/2019, 11:44 AM
    Hello, Is there any standard function with similar behaviour (ifNull extension function)? Or maybe there are some nice idiomatic ways to do that?
    -.kt
    m
    a
    • 3
    • 11
  • o

    otakusenpai

    01/30/2019, 1:03 PM
    Hello, I'm trying to make a FEN parser, and in that I have to parse something like this:- "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" What I do now is that I just split that string using split(' ') into a List<String> and on the first string of the list, any value can have 1,especially on the rnbqkbnr/ppp... and their uppercase counterparts, and when its 1 I have to just ignore it(I'm using a when statement). My question is how do I ignore a case in a when statement since break and continue aren't applicable(Yup, I know it's a noobish question).
    p
    h
    +2
    • 5
    • 16
  • s

    serebit

    01/30/2019, 3:47 PM
    Seems fine to me
    👍 1
    k
    • 2
    • 1
  • k

    karelpeeters

    02/01/2019, 11:15 AM
    .mapNotNull { it.foo }.filter { barFunction(it) }
    👍 2
    d
    p
    +2
    • 5
    • 15
  • b

    Bernhard

    02/04/2019, 12:50 PM
    it’s kinda like async, but the api that I use is not async
    t
    • 2
    • 1
  • b

    Bernhard

    02/04/2019, 1:04 PM
    am I asking in the right channel?
    👍 1
    p
    a
    • 3
    • 3
  • b

    Bernhard

    02/04/2019, 1:37 PM
    runBlocking should just block until everything is finished I think
    • 1
    • 1
Powered by Linen
Title
b

Bernhard

02/04/2019, 1:37 PM
runBlocking should just block until everything is finished I think
at least it looks like it’s needed to run the await functions
View count: 3