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
announcements
  • x

    xenoterracide

    06/10/2019, 4:43 PM
    if not Double::class what should I be comparing it to?
    s
    m
    • 3
    • 10
  • a

    Andrew Gazelka

    06/11/2019, 12:06 AM
    I guess this is a workaround although it is kinda jank
    g
    l
    • 3
    • 56
  • b

    brett.wooldridge

    06/11/2019, 6:03 AM
    Anyone here from the Kotlin coroutine team?
    e
    • 2
    • 4
  • p

    Paul Woitaschek

    06/11/2019, 8:52 AM
    Is there a better way to interop between ruby and kotlin than calling
    exec
    on a script? I have some CI scripts where I use fastlane but whenver I need to write stuff in ruby it kind of breaks my head
    g
    • 2
    • 8
  • m

    mzgreen

    06/11/2019, 12:34 PM
    Why there is no `shr`/`shl` for
    UByte
    ?
    h
    r
    i
    • 4
    • 4
  • m

    mzgreen

    06/11/2019, 1:40 PM
    Second question - if I write
    val foo = 0x1u
    it's treated as
    Int
    . Is there a way to make it something else without providing a type? For example:
    val foo: UByte = 0x1u
    
    when(foo) {
        0x1u -> {} // doesn't work because 0x1u is treated as an Int
    }
    I can do
    0x1.toUByte()
    but it's ugly. Is there maybe something like
    0x1ub
    suffix or sth like that?
    r
    • 2
    • 4
  • e

    efemoney

    06/11/2019, 1:42 PM
    The
    use-experimental
    compiler argument either does not work as advertised (has a bug) or is not configured properly. Whats the correct way to configure the
    use-experimental
    compiler argument with gradle (kotlin dsl) such that I do not get warnings for using experimental APIs in my code? Right now I have this
    subprojects {
    
      // ... 
    
      project.tasks.withType<KotlinCompile> {
        kotlinOptions {
          freeCompilerArgs = listOf(
            "-Xuse-experimental=kotlin.Experimental,kotlinx.coroutines.ExperimentalCoroutinesApi,kotlinx.serialization.ImplicitReflectionSerializer"
          )
        }
      }
    }
    in my root build gradle file but I still get warnings like in the attached image (both
    Flow
    and
    fun dispatcher.invoke( ... )
    are experimental APIs)
    n
    i
    • 3
    • 15
  • n

    Nikky

    06/11/2019, 4:50 PM
    since i do not really know how to ask the question (with limited knowledge) how can i setup exposed, squash or any other database library to write and save data classes that may have lists of, maps of or just references to other data classes (i assume multiple tables) and have this accessible in a single function to store and retrieve objects, is there automatic shortcuts or would i have to reconstruct the objects along with retrieving the contained info manually ? does anyone have some example code?
    p
    • 2
    • 1
  • p

    Paul N

    06/11/2019, 8:03 PM
    Is there a way of delaying evaluation of string templates ? So if I have this at a class level
    val baseURL = "http://$domainName/endpoint"
    and then a function like this
    fun someMore(domainName : String, somethingElse : String) {
    val x = "$baseURL$somethingElse
    }
    then x should equal http://mydomainname/endpoint/mysomethingElse if I pass in mydomainname and mysomethingelse to the function ?
    l
    s
    +3
    • 6
    • 12
  • r

    Rohan Maity

    06/11/2019, 10:12 PM
    I saw byte code for
    val variable = 90
    and in the decompiled bytecode it produced
    int variable = true;
    . I don't understand this ?
    c
    k
    +2
    • 5
    • 8
  • e

    elect

    06/12/2019, 9:22 AM
    some elegant solution for allocating a not-nullable array as buffer for a generic ringBuffer implementation since I cant use inline reified? The only option I see is to pass down as argument the class itself
    d
    c
    • 3
    • 23
  • j

    Jonathan Mew

    06/12/2019, 11:16 AM
    Sorry, I just created a channel #junit when I just meant to search for it. It can be deleted (but I can't do that!)
    💪 1
    k
    • 2
    • 1
  • f

    Florian

    06/12/2019, 12:21 PM
    why is the min and max value of Double and Float declared like this: public val MIN_VALUE: Double public val MAX_VALUE: Double
    p
    e
    • 3
    • 6
  • c

    chansek

    06/12/2019, 1:56 PM
    Where as this doesn't.
    :thread-please: 3
    d
    c
    t
    • 4
    • 7
  • s

    Shawn

    06/12/2019, 2:00 PM
    scoping, my dude
    m
    s
    m
    • 4
    • 3
  • x

    xenoterracide

    06/12/2019, 5:59 PM
    val monitor = useCase.findMonitor(dto.monitorSn)?.also {
                useCase.connect(transform(dto))
            }
            if ( monitor == null ) {
                log.error("monitor {} not found", dto.monitorSn )
            }
    is there a nicer way to do the monitor == null as sort of an
    orElse { ... }
    l
    r
    +4
    • 7
    • 13
  • d

    dMusicb

    06/13/2019, 1:27 AM
    Is it possible to have a data class that has a java class as a property? Was getting an issue when comparing two equivalent data classes. Found out there was no toEquals/toString override on the java class so it was showing the class@hash value. I added those methods to the class and I see the data classes now have the same values but it’s still failing the comparison.
    g
    • 2
    • 7
  • r

    rrader

    06/13/2019, 6:48 AM
    is a sealed class an abstract class?
    g
    t
    +2
    • 5
    • 15
  • d

    David

    06/13/2019, 9:37 AM
    I want to chat kotlinx-serialization …anyone know of good channel for that kind of thing?
    h
    m
    k
    • 4
    • 6
  • b

    bod

    06/13/2019, 11:30 AM
    Hello, World! Any idea if it's possible to show an image in a KDoc comment? Apparently in Javadoc doing
    <img src="/doc-files/session-state.png">
    worked - but it doesn't seem to work with Kotlin. Ideas?
    a
    • 2
    • 4
  • g

    Guilherme Titschkoski

    06/13/2019, 12:47 PM
    does kotlin has a equivalent to C#
    where T : new()
    ?
    m
    • 2
    • 1
  • n

    Nezteb

    06/13/2019, 5:12 PM
    What are people’s favorite Kotlin/Java libraries for providing HTTP/REST APIs?
    s
    j
    +2
    • 5
    • 5
  • v

    ValV

    06/13/2019, 6:13 PM
    Hi, guys! What is the best practice to store sensitive user data like passwords (local disk, database) in an app? Does Kotlin have some specific encryption libraries?
    :stackoverflow: 2
    x
    • 2
    • 2
  • x

    xenoterracide

    06/13/2019, 7:28 PM
    I feel like I’ve seen code like this written
    deserialize<PatientDto>(message.payload)
    where the called method then gets the class
    internal fun <DTO : Any> deserialize( ba: ByteArray, clazz: KClass<DTO> ): DTO {
            return mapper.readValue(ba, clazz.java)
        }
    pretty sure it’s in gradle’s kotlin DSL somewhere… how do I replicate that calling signature?
    c
    p
    c
    • 4
    • 7
  • w

    william

    06/13/2019, 9:25 PM
    if i have a few functions that have a default argument of
    onComplete: () -> Unit = {}
    would it be best to put this no-op function in a companion object somewhere or does kotlin automatically do any optimizations ?
    k
    • 2
    • 3
  • n

    Nick Tiller

    06/13/2019, 10:14 PM
    I have a weird situation and I was wondering if anyone has a solution. I have a couple data classes from a shared library that are structured very similarly.
    data class Foo(val width: Float, val height: Float, val x: Float, val y: Float)
    data class Bar(val width: Float, val height: Float, val x: Float, val y: Float)
    To construct them, I have to write something like
    when(clss) 
        is Foo -> constructFoo()
        is Bar -> constructBar()
    with each of those construct methods doing the exact same thing (setting the same variable names & types). Is there a structure or something in Kotlin that I can use to make this cleaner?
    k
    j
    • 3
    • 4
  • w

    william

    06/13/2019, 11:20 PM
    if i have a getter / setter in java can i override it with a var getter and setter?
    • 1
    • 1
  • h

    Hullaballoonatic

    06/14/2019, 12:24 AM
    Why is
    Number
    not operable in the JVM? Why did Sun design it that way and why does JB not fix it in Kotlin? Everything (afaik) that inherits from
    Number
    is operable, so why wouldn't the operators be refactored to be included there?
    s
    • 2
    • 37
  • a

    Antanas A.

    06/14/2019, 6:49 AM
    Hi, It would be nice that extension functions such us
    inline fun <T> T.takeUnless
    would work lazily and short circuit code execution if condition is true, kind of lazy evaluation of
    previous expression
    . What's your thoughts? Is it possible at all?
    g
    p
    d
    • 4
    • 20
  • x

    xenoterracide

    06/14/2019, 4:24 PM
    what do I need to add to make it work?
    k
    • 2
    • 4
Powered by Linen
Title
x

xenoterracide

06/14/2019, 4:24 PM
what do I need to add to make it work?
k

karelpeeters

06/14/2019, 6:25 PM
Where do you get that error?
x

xenoterracide

06/14/2019, 6:32 PM
the java compiler
for the time being I’ve switched the library to expose a
Consumer
rather than a kotlin function
k

karelpeeters

06/16/2019, 7:57 AM
Do you have the kotlin stdlib on the Java compiler's classpath?
View count: 5