https://kotlinlang.org logo
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
  • u

    ursus

    07/15/2019, 12:58 AM
    i'm SOL, right?
    s
    m
    • 3
    • 24
  • s

    Sudhir Singh Khanger

    07/15/2019, 4:10 AM
    if (nullableIntOne ?: 0 < nullableList?.size ?: 0) {
        // some code 1
    } else {
        // some code 2
    }
    I can't compare nullable types. So what is the likelihood of above code breaking. How can I mitigate it?
    j
    g
    • 3
    • 7
  • r

    rdgoite

    07/15/2019, 2:32 PM
    Hello everyone. Does anyone know how to properly protect collection type properties? What I want to do is to clone the collection into an immutable one every time
    get()
    is called. However, I just found out that defining something like,
    var myCollection: MutableList<String> = mutableListOf()
        private set
        get() = field.toMutableList()
    is problematic because calling
    this.myCollection
    within the class itself seem to call the getter instead. My current alternative is to make it immutable collection and replace it every time there are changes. However, that seems to be a little more work than it should be. Any ideas?
    s
    • 2
    • 5
  • n

    Nikolai

    07/15/2019, 4:34 PM
    Hi, everyone I am continuing to learn gradle things. If I create an multiplatform project in Idea it will have two build.gradle files inside. One is the root with following content :
    buildscript {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.0'
        }
    }
    repositories {
        google()
        jcenter()
    }
    Why we need repositories here? According to docs it configure repositories for current project. But this is the root file. And it have repositories inside buildscript. This repositories didn't count for subprojects (whats why child build.script have it's own repositories closure). If I remove it - nothing changes, app still build and run (at least on Android). In Android studio this closure looks like :
    allprojects {
      repositories {
          google()
          jcenter()
      }
    }
    Which is quite understandable. Maybe I am missing something and this repository closure have some purpose?
    c
    • 2
    • 2
  • k

    Katie Levy

    07/15/2019, 4:43 PM
    Checkout this webinar on how Kotlin is making our lives as engineers easier at Intuit: http://bit.ly/Kotlinwebinar
    👍 3
    r
    m
    • 3
    • 2
  • n

    nwh

    07/15/2019, 7:29 PM
    Is it possible to seamlessly wrap something like an
    Optional
    ? Where there are three valid values: regular value, null, nothing. I'm using a data class so a
    lateinit var
    isn't exactly the best solution
    j
    s
    g
    • 4
    • 12
  • s

    Stefan Peterson

    07/15/2019, 11:51 PM
    So I am trying to work on my first Kotlin/Native project and hit a snag when trying to use
    BigDecimal
    . Since it is a Java stdLib object, I don't have access to it. I need to do some pretty high precision math that I don't want to be in base-2, are there any good Kotlin alternatives?
    k
    • 2
    • 1
  • m

    Mike R

    07/16/2019, 1:29 AM
    Are any of the channels here an appropriate place to ask a question about using Gson with Kotlin? Gson or Retrofit, really.
    j
    • 2
    • 2
  • a

    Andrew Gazelka

    07/16/2019, 4:38 AM
    anyone want to give me their philosophy of when to use data classes vs interfaces?
    k
    d
    c
    • 4
    • 10
  • a

    Andrew Gazelka

    07/16/2019, 4:56 AM
    does Kotlin have an easy way to have non-blocking file IO?
    s
    • 2
    • 2
  • k

    kevindmoore

    07/16/2019, 5:01 AM
    Coroutines
    a
    k
    p
    • 4
    • 6
  • s

    Syed Faraz

    07/16/2019, 9:10 AM
    sealed class Operation <out T> {
    
       data class InsertOperation<out T>(var insertedData: ArrayList<T>)
    }
    Hi, this gives
    type parameter t is declared as 'out' but occurs in 'invariant' position in type t
    , can anyone tell me what is correct way of handling this type of variance checking?
    d
    m
    • 3
    • 7
  • p

    Paul N

    07/16/2019, 10:04 AM
    So I got an IntelliJ out of memory error, and now all my Kotlin projects which were building fine in IntelliJ, are peppered with red all over the place. Example errors are listOf, it and lazy being an unresolved reference. The projects are gradle based and still build perfectly in gradle, Any ideas ? IntelliJ 2019.1.3 ultimate, Kotlin plugin v1.3.41-release-IJ2019.1-1
    k
    l
    • 3
    • 4
  • a

    alex

    07/16/2019, 11:57 AM
    Java/Kotlin question about NonNull and primitive arrays:
    @Value
    public final class Url {
      @NonNull
      private URL url;
      @NonNull 
      private byte[] signature;
    }
    but in Kotlin it's always treated like
    ByteArray!
    . Apart from that, NonNull is marked with warning: primitive type members cannot be annotated. Any idea what could be wrong? NonNull annotations are from checker framework.
    k
    a
    • 3
    • 7
  • n

    Nikola Milovic

    07/16/2019, 4:32 PM
    Yo guys how many job openings are there for kotlin? I got pretty comfortable with it but whenever i look at job offers its all java and if you know kotlin its just a bonus
    m
    c
    +2
    • 5
    • 8
  • j

    Jeff

    07/16/2019, 5:01 PM
    Anyone using exclusively Spock to test Kotlin classes? I'm seeing some issues with using a Spock Mock for a Kotlin interface where the stubbed methods are returning null. Wondering if there's something odd with the interop that I'm missing...
    • 1
    • 1
  • j

    Juanoterocas

    07/16/2019, 7:20 PM
    Hi, I have updated kotlin 1.3.21 to 1.3.41 and I'm getting IDE errors about type mismatch, This happens with requery library : Type mismatch. Required: Condition<out Expression<TypeVariable(R)>, *> Found: Logical<out Expression<Long>, Long> I know Logical inherits from Contidion but type can't be inferred . Any Workaround?
    k
    j
    a
    • 4
    • 6
  • x

    xenoterracide

    07/16/2019, 9:38 PM
    anyone seen this from idea?
    Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
    	at com.potreromed.ApplicationKt.main(Application.kt)
    Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    	... 1 more
    I get it when trying to run a very simple application class...
    @SpringBootApplication
    open class Application
    
    fun main(args: Array<String>) {
        runApplication<Application>(*args)
    }
    k
    • 2
    • 1
  • a

    Andrew Gazelka

    07/17/2019, 12:33 AM
    I have used Klaxon for JSON parsing for a bit but I can’t find if there is a function to merge JSON documents. Anyone know if there is one? If there isn’t anyone know of a good lib for this?
    e
    • 2
    • 2
  • b

    bbaldino

    07/17/2019, 6:27 AM
    i have a generic class and want to define an inner interface to define a handler for that type (which would include the generic). i.e.:
    class Foo<T> {
       ...
       inner interface FooEventHandler {
         fun event(value: T)
       }
      }
    but it looks like this isn't possible (it says
    inner
    can't be used with
    interface
    ). is there a good way to accomplish something like this? i don't want the user to have to define the generic type in 2 places (once for Foo and once for instantiating a FooEventHandler, because it could only lead to a mistake)
    k
    • 2
    • 3
  • v

    Vladimir Ivanov

    07/17/2019, 11:09 AM
    Folks, how can I use Flow in a similar manner of ConflatedBroadcastChannel? I want to send a message coming from UI to a stream. BroadcastChannel had an offer method, what do I do with Flow ?
    t
    l
    • 3
    • 3
  • g

    gregorbg

    07/17/2019, 12:05 PM
    Hey there! What would be an appropriate channel to discuss gRPC style and best practices in Kotlin?
    k
    g
    • 3
    • 3
  • a

    Alexjok

    07/17/2019, 12:17 PM
    Hi! Where i can find retry function?
    k
    • 2
    • 2
  • n

    Nikolai

    07/17/2019, 2:27 PM
    Hi, is where any way to look into source code of Gradle task(s) added by plugin ( I mean Kotlin-Multiplatform and I guess Android plugins )?
    b
    m
    • 3
    • 8
  • m

    Max

    07/17/2019, 3:48 PM
    Hello everyone, does anybody have any experience with MockK? I'm currently stuck on a stackoverflow error due to mocking functions of an interface but without any special behaviour...
    m
    • 2
    • 1
  • m

    mathew murphy

    07/17/2019, 4:06 PM
    Any Moshi experts here?
    j
    • 2
    • 2
  • j

    Joe

    07/17/2019, 5:30 PM
    Having a question with respect to using the
    ?:
    elvis operator to provide a default: If I have reasonable tests around code that does something like:
    val x = nullableObject?.method() ?: default
    JaCoCo tells me I have one of 4 branches uncovered. If I change that to:
    val nullableX = nullableObject?.method()
        val x = nullableX ?: default
    JaCoCo tells me all branches are covered (2 branches per line). I'm guessing the "uncovered" branch is when
    nullableObject
    is non-null, but
    method()
    returns null -- is there a way to get JaCoCo to realize that branch is not possible based on
    method()
    not being nullable? Or is there a better practice here?
    e
    • 2
    • 3
  • b

    bbaldino

    07/17/2019, 7:51 PM
    maybe this is a dumb question: can i create an instance of a private inner class from the outer class? i'm getting a runtime error about
    java.lang.VerifyError: Call to wrong <init> method
    • 1
    • 4
  • l

    Luke

    07/17/2019, 8:53 PM
    Out of curiosity, is there a reason why the parentheses of a function without parameters are not optional?
    s
    r
    s
    • 4
    • 10
  • j

    JP Wang

    07/17/2019, 9:30 PM
    Hi all, are there any well-known apps built on Kotlin/Multiplatform?
    m
    s
    +3
    • 6
    • 12
Powered by Linen
Title
j

JP Wang

07/17/2019, 9:30 PM
Hi all, are there any well-known apps built on Kotlin/Multiplatform?
m

mbonnin

07/17/2019, 9:33 PM
I usually look at the kotlin conf app 🙂
j

JP Wang

07/17/2019, 9:34 PM
yes. but any production app…
m

mbonnin

07/17/2019, 9:34 PM
Well, it's in production 🙂
And will be again at the end of the year
In general, Kotlin is fairly used for Android Apps nowadays, a lot of them contain a majority (if not exclusively) kotlin.
Now for iOS/macOS, I'm interested in examples as well
s

Shawn

07/17/2019, 9:36 PM
I think more pertinent to your question, the vast majority of publicly visible Kotlin projects run on the JVM in some form
Kotlin MPP is definitely a bit more experimental, though I’m sure there’s someone out trialling it in production
j

JP Wang

07/17/2019, 10:47 PM
yeap, really want to hear if anyone/company publishes IOS app with Kotlin/Native
a

alex009

07/18/2019, 1:59 AM
yes, we use it on production... more info - https://medium.com/icerock/the-dos-and-donts-of-mobile-development-with-kotlin-multiplatform-db7c098545c0 https://medium.com/icerock/the-dos-and-donts-of-mobile-development-with-kotlin-multiplatform-part-ii-d318dae8475b
👍 1
r

ribesg

07/18/2019, 7:57 AM
Not in production yet, but our app uses MPP libraries and should be out on iOS and Android in the next weeks
e

epabst

08/02/2019, 12:55 AM
I just published an update to my app to move it to MPP. It's still KotlinJS but built using the new MPP build and coroutines, . https://apps.apple.com/us/app/future-balance/id1230838610?ls=1
View count: 3