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
random
  • t

    todd.ginsberg

    02/17/2022, 1:36 PM
    Does anybody at JetBrains have any pull at all with somebody at leetcode? Their Kotlin interpreter is version 1.3 and I can’t find anything about any plans to upgrade it to something more recent. Also, continually using
    val
    as the name of a property is annoying and not idiomatic, but I can live with that if they truly can’t fix that. (Note: I fully realize that JB has absolutely nothing to do with leetcode, just asking if there’s been any discussions re: versioning)
    s
    k
    6 replies · 3 participants
  • r

    Ryan Rolnicki

    02/19/2022, 2:52 PM
    Reddit question, but curious if anyone knows - why does function declaration use ":" to designate the return type, but lambda syntax uses "->"? Was there some language design reason this was required?
    e
    a
    +1
    8 replies · 4 participants
  • v

    Vivek Modi

    02/19/2022, 6:34 PM
    Hey anyone know to default selection in RecyclerView Android kotlin
    1 reply · 1 participant
  • d

    dewildte

    02/21/2022, 12:58 AM
    I am trying to login into the Space plugin for my IDE. I am blocked by a sign in dialog in my web browser. I have tried my Space login credentials and my PC login credentials. Neither has worked. What do I need here?
    1 reply · 1 participant
  • a

    andylamax

    02/21/2022, 12:50 PM
    😂 16
    h
    j
    +4
    8 replies · 7 participants
  • s

    Sola

    02/21/2022, 4:39 PM
    Is it just me? the highlighting for Kotlin in Slack is broken right now, it always highlighted as C++
    s
    k
    +1
    7 replies · 4 participants
  • k

    kenkyee

    02/22/2022, 3:39 PM
    Kotlin slack is surviving a lot better than other Slack workspaces this morning 😂 🎉
    :kotlin-intensifies-purple: 2
    t
    1 reply · 2 participants
  • t

    Trammel May

    02/22/2022, 7:59 PM
    anyone a fleet expert yet? I have questions. (I am not a VSCode user and primarily use jetbrains products)
    t
    t
    3 replies · 3 participants
  • y

    Youssef Shoaib [MOD]

    02/23/2022, 6:11 PM
    I made a thing that, quite honestly, will make Roman Elizarov smite me...
    fun main() {
        println((2 + 2 == 4) `?` {42} `:` {5})
    }
    
    @JvmName("questionMark")
    infix fun <T> Boolean.`?`(block: () -> T): IfResult<T> = IfResult<T>(if(this) block() else ElseIndicator)
    
    @Suppress("INVALID_CHARACTERS")
    @JvmName("colon")
    infix fun <T> IfResult<T>.`:`(block: () -> T): T = if(isElse) block() else result as T
    
    object ElseIndicator
    @JvmInline value class IfResult<T> internal constructor(internal val result: Any?) {
        val isElse get() = result == ElseIndicator
    }
    (psssst, it works for bitwise operators too...)
    🤣 5
    😍 3
    l
    m
    +1
    7 replies · 4 participants
  • b

    bryan

    02/24/2022, 3:15 AM
    🇺🇦 ❤️😢
    ❤️ 11
    🇺🇦 15
    ➕ 24
    t
    1 reply · 2 participants
  • t

    trevjones

    02/24/2022, 6:09 PM
    https://www.reddit.com/r/Kotlin/comments/t0e7gh/slightly_offtopic_but_thank_you_jetbrains_for/
    😮 2
    👍 5
    👏 2
    ❤️ 2
    k
    t
    +3
    9 replies · 6 participants
  • s

    Sam

    02/25/2022, 2:24 PM
    Today I realised that because
    return
    is an expression (of type
    Nothing
    ), you can
    return return
    .
    fun madness() {
        return return return return return return return return return return
    }
    😄 14
    :kotlin-intensifies: 11
    😂 17
    :lol: 7
    k
    r
    +2
    5 replies · 5 participants
  • v

    vova.bilous

    02/28/2022, 5:16 PM
    Dear Friends, my country Army need ur help! https://uahelp.monobank.ua
    🇺🇦 8
    m
    1 reply · 2 participants
  • u

    ursus

    03/01/2022, 3:57 AM
    Anybody with logitech mx master 3 mouse and a mac?
    h
    t
    +2
    14 replies · 5 participants
  • m

    Marc Reichelt

    03/03/2022, 5:02 PM
    Hey there! Is there any way to get the file name in a Kotlin file? This functionality could be helpful with e.g. logging, where the other approaches have drawbacks: • need to manually define tag (manual, can be messed up when filename changes) • or: throw a full
    Throwable()
    , to only get the file / class name (performance issues) • or: using
    reified
    to get the class name (will print weird log tags when scope changes (e.g. it will print
    CoroutineScope
    in some instances))
    e
    s
    +4
    18 replies · 7 participants
  • b

    bogdoll

    03/05/2022, 1:39 PM
    Is the map returned by mutableMapOf(...) multihread-capable? E.g. is it a ConcurrentHashMap or something similiar? If not, what map should I use in multithreading environment. e.g ConcurrentHashMap?
    d
    r
    +1
    5 replies · 4 participants
  • l

    LeoColman

    03/06/2022, 1:14 AM
    Hey guys! Is there any channel for Kover? I searched it but only found an archived one. Where does discussion about Kover occur?
    k
    1 reply · 2 participants
  • p

    pablisco

    03/08/2022, 11:49 PM
    Not sure where to ask this 😅 Regarding Contracts, I was wondering if it’s possible (or will ever be) to signal something about a parameter if a lambda is called. Like this:
    l
    5 replies · 2 participants
  • s

    Sam

    03/10/2022, 2:02 PM
    I really want a
    <http://DeprecationLevel.INFO|DeprecationLevel.INFO>
    . It would be super useful within a large codebase, where I need to signal intent to other developers without littering the place with compiler warnings. Is it something that's ever been discussed? I'll raise a ticket if not.
    c
    7 replies · 2 participants
  • k

    kqr

    03/13/2022, 3:37 PM
    please how is this affecting kotlin's team and kotlin's future? https://blog.jetbrains.com/blog/2022/03/11/jetbrains-statement-on-ukraine/
    r
    c
    +1
    6 replies · 4 participants
  • t

    therealbluepandabear

    03/13/2022, 11:03 PM
    Hi, If you haven't already seen in the past, I've posted an issue about how It's time all JetBrains based IDEs give the user the option to change their default search engine from 'Search with Google' to 'Search with DuckDuckGo/Bing' to promote freedom-of-choice. And remember, this isn't about 'cancelling' Google or anything. Google will still remain as the default search engine, all this feature is about is just giving the user the simple freedom-of-choice to change their search engine for this otherwise useful feature. Reasons people might want to change their default search engine from Google to an alternative: • For privacy reasons (some people like to use DDG/Qwant/Brave Search) • For easily being able to search queries directly on sites such as StackOverFlow or Github • And in some countries (as someone mentioned below) Google is blocked This issue has been gaining some traction, and I'd encourage everyone who is interested in getting this feature into the next update to please look, I've written in detail about my proposal below and why I believe it's important JetBrains add this feature: https://youtrack.jetbrains.com/issue/IDEA-289262 If you think it's good please like 👍 the issue so we can get this in the next update ASAP, and JetBrains listens to us. Also before commenting anything, please read the whole issue. If you have any other questions, check if they are answered there: for example, I speak about the Smart Search plugin and why I believe direct-IDE support is better than plugin support, I also go in detail about how this feature will work, etc. If you have any feedback let me know.
    👍 5
    s
    2 replies · 2 participants
  • j

    Jason5lee

    03/15/2022, 8:26 AM
    Suppose you're writing a REST API service. You want to query a data from DB, and if no record found, you response a 404 not found. I have two possible implementations. 1.
    class SomethingNotFoundException : Exception()
    
    // DB query side
    if (result.isEmpty()) {
        throw SomethingNotFoundException()
    }
    
    // API implement
    try {
        ....
    } catch (e: SomethingNotFoundException) {
        return HttpResponse(404, "SOMETHING_NOT_FOUND")
    }
    2.
    // DB query side
    if (result.isEmpty()) {
        throw HttpException(404, "SOME_THING_NOT_FOUND")
    }
    where
    HttpException
    is handled by the framework or a single
    catch
    that extracts the response parameter from the exception fields. The second approach is simpler, but it couples with the protocol as you involves the HTTP exception and related concept like status code. Which one would you choose?
    s
    r
    +3
    17 replies · 6 participants
  • j

    Jason5lee

    03/15/2022, 10:21 AM
    My previous problem, but since many people suggest NOT using exception, I asked the non-exception version. Which of the following is your preferred way to define error? 1.
    sealed class QueryResult {
        data class Success(...) : QueryResult()
        object NotFound : QueryResult()
        object SomeOtherError : QueryResult()
    }
    
    // API Code
    when(result) {
        is QueryResult.Success -> HttpResponse(200, "...")
        QueryResult.NotFound -> HttpResponse(404, ...)
        ...
    }
    2.
    sealed class QueryResult {
        data class Success(...) : QueryResult()
        data class Error(val status: HttpStatus, ...) : QueryResult()
    }
    
    // API Code
    when (result) {
        is QueryResult.Success -> HttpResponse(200, ...)
        is QueryResult.Error -> HttpResponse(result.status, ...)
    }
    The second way is more convenient but the
    Error
    type is coupled with the HTTP protocol.
    e
    r
    2 replies · 3 participants
  • o

    Olek Brzozowski

    03/15/2022, 12:45 PM
    Why kotlin allows such code? 😉
    throw throw RuntimeException("i am double throw")
    k
    y
    +2
    6 replies · 5 participants
  • y

    Youssef Shoaib [MOD]

    03/16/2022, 12:42 AM
    Here's a quick sneak-peek on a hobby project I've been working on just for the fun of it. This is 4 different ways to do multiplication using add and shift, all in a DSL I'm working on that generates ARM code out of Dsl calls:
    fun ArmBuilder.multiply2(
        first: ArmTransferableValueOperand, second: ArmTransferableValueOperand
    ): ArmCalculationOperand = buildSubroutine("multiply2", first, second) {
        var operand1 by register(first)
        var operand2 by register(second)
        operand1.compare(operand2, "optimizeSmallerValue") {
            greaterThan("swapValues") {
                swap(operand1 as ArmStorageOperand, operand2 as ArmStorageOperand)
            }
        }
        result = constant(0)
        val mainLoop by labeled
        val mainLoopEnd by labeled
        label(mainLoop)
        operand1.compare(constant(0), "rangeCheck") {
            lessThan = mainLoopEnd
            equal = lessThan
        }
        If(operand1 and constant(1), "oddCheck") {
            result += operand2
        }
        operand2 = operand2 shl constant(1)
        operand1 = operand1 shr constant(1)
        branch(mainLoop)
        label(mainLoopEnd)
    }
    
    fun ArmBuilder.multiply3(
        first: ArmTransferableValueOperand, second: ArmTransferableValueOperand
    ): ArmCalculationOperand = buildSubroutine("multiply3", first, second) {
        var operand1 by register(first)
        var operand2 by register(second)
        If(operand1 greaterThan operand2, "swapValues") {
            swap(operand1 as ArmStorageOperand, operand2 as ArmStorageOperand)
        }
        result = constant(0)
        val mainLoop by labeled
        val mainLoopEnd by labeled
        label(mainLoop)
        If(operand1 lessThanOrEqual constant(0), "rangeCheck") {
            branch(mainLoopEnd)
        } Else If(operand1 and constant(1), "oddCheck") {
            result += operand2
        }
        operand2 = operand2 shl constant(1)
        operand1 = operand1 shr constant(1)
        branch(mainLoop)
        label(mainLoopEnd)
    }
    
    fun ArmBuilder.multiply4(
        first: ArmTransferableValueOperand, second: ArmTransferableValueOperand
    ): ArmCalculationOperand = buildSubroutine("multiply4", first, second) {
        var operand1 by register(first)
        var operand2 by register(second)
        If(operand1 `>` operand2, "swapValues") {
            operand1.out `<->` operand2.out
        }
        result = 0.c
        While(operand1 `>` 0.c, "mainLoop") {
            If(operand1 `&` 1.c, "oddCheck") {
                result += operand2
            }
            operand2 = operand2 `<<` 1.c
            operand1 = operand1 `>>` 1.c
        }
    }
    
    fun ArmBuilder.multiply5(
        first: ArmTransferableValueOperand, second: ArmTransferableValueOperand
    ): ArmCalculationOperand = buildSubroutine("multiply4", first, second) {
        val operand2 = register(second)
        result = 0.c
        For(first, { it `>` 0.c }, { it `>>=` 1.c; operand2 `<<=` 1.c }, "mainLoop") { operand1 ->
            If(operand1 `&` 1.c, "oddCheck") {
                result += operand2
            }
        }
    }
    (Yes some of these look horrendous, but it's all meant just to show off the current features with a trivial example)
    1 reply · 1 participant
  • m

    Marcello Galhardo

    03/16/2022, 9:33 AM
    Folks, a curious question: I really enjoying reading Design Proposal from the Kotlin Team (ie, Context Receivers) and I find its quality outstanding - so I was wondering… is there any comprehensive material on how the Kotlin Team approach these Design Proposals? Any reference would be really appreciated. 🙂
    s
    1 reply · 2 participants
  • y

    Youssef Shoaib [MOD]

    03/17/2022, 11:28 AM
    IDEA takes a stance on the pronunciation of SQL 😄 (the screenshot says "an SQL" which is only valid if you pronounce it as S Q L, while a SQL is valid if it's SeQueL) Also how dare they use lowercase letters for SQL keywords
    😂 1
    t
    k
    2 replies · 3 participants
  • r

    Rob Elliot

    03/17/2022, 3:56 PM
    Anyone know of a slack /discord / irc where people discuss the JVM? I really want to ask for some advice on
    ModuleLayer
    and how to use it.
    t
    1 reply · 2 participants
  • j

    Jason5lee

    03/19/2022, 2:39 AM
    Is there any particular reason that JB compose not supporting iOS, while supporting most other major platforms and web?
    t
    1 reply · 2 participants
  • u

    ursus

    03/19/2022, 11:01 PM
    Hey, I’m trying to get a working knowledge of ios/swift (to get kmp going) Does someone here know what’s the state of the art for ios in terms of libraries? 1. What’s the go to persistance library? (is sqlite popular as well?) 2. What’s the go to networking library? 3. What’s the go to DI library? 4. What’s the go to reactive framework? (I read there is frst party Combine?) 5. What’s the status of async-await? Does it play nice with Combine as suspend functions do with kotlin Flow? 6. Should I still bother to learn UIKit when swift ui exists? Is it not prod ready?
    a
    p
    4 replies · 3 participants
Powered by Linen
Title
u

ursus

03/19/2022, 11:01 PM
Hey, I’m trying to get a working knowledge of ios/swift (to get kmp going) Does someone here know what’s the state of the art for ios in terms of libraries? 1. What’s the go to persistance library? (is sqlite popular as well?) 2. What’s the go to networking library? 3. What’s the go to DI library? 4. What’s the go to reactive framework? (I read there is frst party Combine?) 5. What’s the status of async-await? Does it play nice with Combine as suspend functions do with kotlin Flow? 6. Should I still bother to learn UIKit when swift ui exists? Is it not prod ready?
a

Alejandro Rios

03/19/2022, 11:09 PM
You can ask in #multiplatform
u

ursus

03/19/2022, 11:18 PM
I mean, not really multiplatform, its a pure ios question. I just think its a good idea to get a sense of regular ios development first before employing kmp
p

Paul Woitaschek

03/20/2022, 5:49 AM
There is #ios though
u

ursus

03/20/2022, 12:59 PM
oh, thanks!
View count: 6