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

    matt tighe

    11/18/2019, 9:28 PM
    How can
    filter {}.isEmpty()
    be simplified? IDE is complaining that it can be
    s
    r
    +2
    • 5
    • 12
  • n

    New111

    11/18/2019, 11:01 PM
    Is there any way to learn Kotlin but similar to the famous
    The C Programming Language
    by Kernighan and Ritchie ? I mean not by lets start with variables etc but more like start with short programs while explaining all Kotlin syntax and then get more complicated functionality.
    h
    b
    • 3
    • 7
  • j

    Joey

    11/19/2019, 7:25 AM
    How to use kotlinx.seriliazation? My project is completely screwed after importing bunch of libraries and still got unresolved reference
    a
    • 2
    • 1
  • s

    Sebi Sheldin Sebastian

    11/20/2019, 6:46 AM
    try working with MapString, Model types
    :thread-please: 4
    j
    • 2
    • 3
  • r

    Rajiv

    11/20/2019, 12:48 PM
    Hello guys, should i install java8 or java10 for kotlin to compile from terminal?
    d
    e
    m
    • 4
    • 6
  • d

    df

    11/20/2019, 3:14 PM
    is there a better way to write this code? I'm not a big fan of telling the compiler "fuck this null check, just trust me"
    get() {
                if (_fulfillmentDetails == null) {
                    _fulfillmentDetails = FulfillmentDetails(this)
                }
    
                return _fulfillmentDetails!!
            }
    d
    m
    • 3
    • 11
  • n

    New111

    11/20/2019, 5:32 PM
    what are the two exclamation marks
    !!
    at the end ^^^ ?
    s
    d
    • 3
    • 10
  • e

    Ellen Spertus

    11/21/2019, 1:47 AM
    I’m trying to provide a default value for a function parameter but have been unable to get the syntax right (and it’s hard to search for function parameters that are themselves functions). Could someone tell me how to correct this?
    fun Payload.toString(errorReporter: (String) -> Unit = { (_: String) -> Unit } )String? { ... }
    s
    • 2
    • 6
  • s

    Shawn Witte

    11/21/2019, 3:31 AM
    Hey everyone, I have kind of a weird thing with generics. I have an
    abstract class A<X,Y,Z: A<X,Y,Z>>
    which I am subclassing to
    class CompositeA<X,Y>: A<X,Y,CompositeA<X,Y>>
    Now,
    A
    has an
    abstract fun copy(): Z
    and
    CompositeA
    has a property
    components: List<A<X,Y,*>>
    . When I try to iterate through objects from
    components
    , call
    copy()
    on them,and put the put the results into a
    List<A<X,Y,*>>
    the IDE gives me an error saying I'm trying to put something of type of type
    A<*,*,*>
    into the List, which is incompatible. I can cast the result of
    copy()
    by using
    as A<X,Y,*>
    , but then I get an unchecked cast warning. Any ideas what I'm not seeing here?
    h
    • 2
    • 2
  • h

    Hullaballoonatic

    11/21/2019, 6:31 PM
    is this only a syntactic difference?
    sealed class Foo {
        object Bar : Foo()
    }
    vs
    sealed class Foo
    
    object Bar : Foo()
    standard class syntax would imply
    Bar
    has its own
    Bar
    object in the first one
    a
    • 2
    • 3
  • h

    Hullaballoonatic

    11/21/2019, 7:15 PM
    Is there a way to enforce an inheriting class provides a static property?
    🇳🇴 3
    b
    • 2
    • 4
  • m

    Mani

    11/21/2019, 7:22 PM
    Folks, need quick help. I am bad with regex. I have a bunch of strings like this
    Ivy Gourd- 2 kg fav_variety : Fresh fav_quantity : 2 kg pcp_packaging_type : Loose packing fav_unit_of_measurement : Per kg fav_average_weight : 2 kg is_assortment : false num_items_assortment : 0 length_mm : 250 breadth_mm : 180 height_mm : 120 dead_weight```
    a
    r
    • 3
    • 12
  • h

    Hullaballoonatic

    11/21/2019, 7:28 PM
    I have a hard time wrapping my head around a difference between
    F
    and
    Foo<F>
    here:
    interface Foo<F: Foo<F>> {
        val a: F
        val b: Foo<F>
    }
    so what is assignable to a and b?
    r
    • 2
    • 4
  • m

    Mark

    11/22/2019, 5:02 AM
    When converting an old java Utils-style class (never instantiated, only containing statics) to Kotlin, do you typically: 1. remove the Utils class completely, and move those methods up to file-level (converting to use extension functions where possible/appropriate) 2. convert the Utils class to use
    object
    modifier 3. keep the Utils class and put the methods in a
    companion object
    2️⃣ 5
    1️⃣ 11
    v
    • 2
    • 1
  • m

    Mark

    11/22/2019, 7:04 AM
    When using a string template like
    took: $`it`ms
    the compiler gives a warning saying the backticks are redundant. But then removing the backticks gives a compiler error!
    j
    i
    • 3
    • 5
  • h

    Hullaballoonatic

    11/22/2019, 10:57 PM
    What stdlib function turns
    foo
    into
    bar
    ?
    val foo = listOf(
      'a' to 1,
      'a' to 2,
      'b' to 3
    )
    
    val bar = mapOf(
      'a' to listOf(1, 2),
      'b' to listOf(3)
    )
    UPDATE: I found the answer
    fun <T, K, V> Iterable<T>.groupBy(
        keySelector: (T) -> K,
        valueTransform: (T) -> V
    ): Map<K, List<V>>
    a
    d
    • 3
    • 9
  • v

    victor-mntl

    11/23/2019, 1:13 PM
    The correct way of making an enum class with parameters for each value of the enum class is:
    enum class Foo1 (val bar:Int) {FIRST(11), SECOND(222)}
    so we would be able to call their
    bar
    value:
    println(Foo1.FIRST.bar)
    11
    Now, if we look at this one (see that it is missing
    val
    between the parenthesis):
    enum class Foo2 (bar:Int) {FIRST(110), SECOND(2220)}
    in this case,
    bar
    doesn't exist on any call to a value of the enum class:
    println(Foo2.FIRST.bar)
    error: unresolved reference: bar
    So, my question is, does it have any utility to create an enum class with arguments without a val or var expression (= with arguments that are not parameters)? Are the values
    110
    and
    2220
    in this example lost?
    🤔 2
    x
    a
    • 3
    • 8
  • f

    Florian

    11/23/2019, 6:53 PM
    besides
    lateinit
    , all properties of a class need to be initialized when the object is constructed, right?
    m
    v
    • 3
    • 8
  • j

    Joey

    11/25/2019, 4:57 AM
    Is it possible to generate random dynamic key like
    push
    in firebase? If yes what is the best way to do this in kotlin?
    y
    m
    • 3
    • 2
  • d

    Dennis Tel

    11/25/2019, 9:28 AM
    Is there a simple way to scaffold a new (library) project for kotlin? Just getting started with kotlin and tried the options in intellij but it creates a project without a test runner which makes it somewhat difficult to run/interact with the code (scratch pads and worksheets seem to be broken and don’t output anything). Any recommendations?
    c
    t
    +3
    • 6
    • 10
  • r

    rikusen0335

    11/25/2019, 11:00 AM
    Copy-pasta from #general Hello, I'm new to Kotlin, and I want to use Exposed with it, but I'm getting
    java.lang.NoClassDefFoundError: org/jetbrains/exposed/sql/Database
    . Does anyone know how this happen and a solution for this? Thanks. This project using Gradle, JVM.
    m
    d
    i
    • 4
    • 43
  • l

    Luismi

    11/25/2019, 11:42 AM
    Hello, How can I create continuous implementation with Kotlin?
    e
    a
    • 3
    • 2
  • o

    oday

    11/25/2019, 11:55 AM
    hey so I’m having an issue with Base64 encoding, it seems whenever I encode a certain string in my app, the result is different from when I use something like base64encode.org, always different
    s
    b
    u
    • 4
    • 8
  • n

    New111

    11/25/2019, 12:02 PM
    Hello, what is the kotlin-native to way to execute another jar (it is not fork !) and then depending on an action restart it or kill it ?
    m
    • 2
    • 1
  • k

    Kstabks

    11/25/2019, 12:57 PM
    Hello, is there any more further explanation why actually creating a wrapper around a primitive value can be very bad for performance? I am trying to understand that in details. Regarding https://kotlinlang.org/docs/reference/inline-classes.html and the introduction
    h
    • 2
    • 1
  • j

    Jukka Siivonen

    11/25/2019, 3:47 PM
    I might me missing something obvious here but I'm trying to introduce nullable function parameter like
    fun <T : Any?> execute(queryId: (() -> UUID)? = null, operation: Operation<T>): T? {
    but I can't invoke this by
    execute(Operation(...))
    only
    execute(null, Operation(...))
    works, any pointers?
    d
    m
    • 3
    • 3
  • v

    victor-mntl

    11/25/2019, 4:10 PM
    Does the pseudo-class
    Map.Entry<K,V>
    (that appears when you select only one entry of a Map) works exactly the same as
    Pair<K,V>
    ? Are there any differences that should be taken care of?
    d
    • 2
    • 3
  • v

    victor-mntl

    11/25/2019, 4:44 PM
    I found that IntelliJ asks me to add an only safe call to the value of an entry of a Map although I first verify that it is non-null
    val mutableMap<String, mutableSet<String>> myMap = mutableMapOf ("first key" to mutableSetOf("value1 of first entry","value2 of first entry"))
    if (myMap["another key"]==null)
    myMap["another key"] = mutableSetOf("value1 of second entry")
    else
    //at this point, we know that myMap["another key"] is NOT NULL
    myMap["another key"].add("value1 of second entry")
    It marks the last line (marked in bold) and says that I should use ?. instead of . because it says the receiver of the call is of type
    MutableSet<String>?
    (nullable) but it is verified that it is not. Am I missing something?
    m
    • 2
    • 10
  • m

    Matthias R

    11/25/2019, 5:07 PM
    Hey I am actually a beginner in Kotlin. So my question is: when I have for example an abstract val status of type status which in the end is just an integer how can I use the val status as Integer(for example to compare to an other integer value) ..?
    m
    • 2
    • 8
  • r

    rikusen0335

    11/26/2019, 11:08 AM
    I want to ask who knows how to disconnect from Datase, using Exposed
    i
    • 2
    • 2
Powered by Linen
Title
r

rikusen0335

11/26/2019, 11:08 AM
I want to ask who knows how to disconnect from Datase, using Exposed
i

Ivan Kubyshkin [JetBrains]

11/26/2019, 11:13 AM
#exposed
r

rikusen0335

11/26/2019, 11:27 AM
Oh sorry I didn't notice that
View count: 4