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

    Slackbot

    02/22/2020, 8:59 PM
    This message was deleted.
    🚔 2
    l
    t
    • 3
    • 2
  • d

    David Whittaker

    02/23/2020, 1:55 AM
    Will Kotlin ever transpile to Dart so we can get rid of that nonsense?
    j
    • 2
    • 1
  • f

    farzad

    02/23/2020, 9:23 AM
    What's the best way of excluding some properties in equals/hashcode of data classes?
    d
    s
    • 3
    • 3
  • r

    Rodrigo Silva

    02/23/2020, 1:03 PM
    Hello all. I'm getting a hard time with kotlinx serialization. Can anyone help?
    k
    • 2
    • 9
  • e

    earroyoron

    02/23/2020, 9:21 PM
    Hi friends, I’m stuck in this problem with flows: I need to have a flow from a file, but keeping it open (as a “tail -f” on the file). I attach more info just in this same thread to keep it “readable”… THANKS A LOT
    s
    e
    • 3
    • 3
  • a

    aaverin

    02/24/2020, 11:25 AM
    Anybody knows anything on how to write custom generators (like constructor or hashcode that are already present by default) in IntelliJ? Probably related to Velocity? Could use some help in #intellij-tricks
    g
    c
    • 3
    • 5
  • m

    Marc Knaup

    02/24/2020, 12:14 PM
    Is there a way to pass these references without having to repeat
    User::
    over and over again? 🤔
    g
    r
    +2
    • 5
    • 34
  • e

    elect

    02/24/2020, 6:40 PM
    is it possible to set break points programmatically?
    d
    l
    s
    • 4
    • 10
  • r

    Robert Jaros

    02/24/2020, 10:51 PM
    Can this be fixed with some kind of casting? https://pl.kotl.in/OTh5QtrfF
    d
    s
    +2
    • 5
    • 11
  • e

    Ellen Spertus

    02/24/2020, 11:01 PM
    I have a
    values: mutableMapOf<String, List<String>
    . Is there a better way of adding items to it than:
    values[key] = (values[key] ?: emptyList()) + value
    My API level is to low for
    getOrDefault()
    .
    d
    m
    • 3
    • 4
  • i

    Isaac Castillo

    02/25/2020, 2:14 AM
    Should I join a bootcamp if I work as a software engineer already? I want a higher paying job.
    w
    • 2
    • 4
  • t

    tim

    02/25/2020, 12:41 PM
    Are there any good sites to get a feel for how popular a package is? I can get the details on bintray but its clunky especially compared to the JS ecosystem (i.e., see npmjs where I can search for a keyword and see metrics about that package and other packages side by side
    r
    a
    • 3
    • 11
  • m

    Matej Drobnič

    02/25/2020, 1:04 PM
    Looking at twitter post above, is there a list of things that get "magically inlined" or is that documented somewhere? For example, I would never consider using
    .indices
    just because it would create additional objects for very slightly better syntax. However, it appears that it does NOT create any new objects, but I cannot find any documentation about that.
    c
    • 2
    • 4
  • a

    Artyom Gornostayev

    02/25/2020, 4:04 PM
    Hey guys. Is there any possibility to provide casting for such a Java class in Kotlin:
    public abstract class NumberExpression<T extends Number & Comparable<?>> extends ...
    I've tried to do this
    (expression as NumberExpression).goe(value)
    , but this does not work. I know, this is not a good practice, just to know... 🙂
    d
    • 2
    • 7
  • t

    Tmpod

    02/25/2020, 6:53 PM
    I set
    1.3.70-eap-274
    everywhere
    t
    • 2
    • 1
  • s

    Sergey Chelombitko

    02/25/2020, 7:12 PM
    Is there any way to override severity for certain type of compile messages? I want to enable
    warningsAsErrors
    but keep deprecated API usage as a warning
    🇳🇴 1
    t
    • 2
    • 1
  • k

    KotlinIsMyFav

    02/25/2020, 10:26 PM
    I am using coroutines for the 1st time, any pointers?
    d
    e
    • 3
    • 3
  • a

    Alexey Anufriev

    02/25/2020, 10:34 PM
    hi guys, I develop a DSL, one of the methods I have called
    to
    inside
    TuplesKt.class
    there is also
    to
    method and in practice when I test the DSL my method is not resolved but the one from
    stdlib
    how ot overcome this?
    d
    k
    l
    • 4
    • 4
  • a

    Alexey Anufriev

    02/26/2020, 8:39 AM
    hi guys, I am trying to add Kotlin support into my existing Java/Maven project folks on the internet advice to execute
    kotlin-maven-plugin
    first and the
    maven-compiler-plugin
    but what if I have in Java annotation processing that is generating some source files, how can I call those from Kotlin?
    n
    • 2
    • 15
  • a

    ahulyk

    02/26/2020, 9:01 AM
    Hi folks 🙂 Hot sure if this is the right thread. Looks like we have an issue with java interoperability in case of using
    inline
    classes in kotlin:
    java interface
    public interface ItemClickListener { //java interface
        void onClick(CollectionData collectionData);
    }
    kotlin data class
    inline class CollectionData(val collectionName: String)
    call from kotlin code
    private fun setListener() {
        listener = ItemClickListener { }
    }
    Error in runtime:
    java.lang.NoSuchMethodError: No interface method onClick-GwgtRiE(Ljava/lang/String;)V in class LItemClickListener; or its super classes (declaration of 'ItemClickListener' appears in /data/app/packagename-Uswa6bR60ndbc7IFGkEVCw==/base.apk!classes2.dex)
    d
    • 2
    • 3
  • s

    Stephan Schroeder

    02/26/2020, 10:12 AM
    There isn’t a way to mix data classes and Delegates (while retaining the type we delegate to), is there??
    fun main() {
        val r1 = Retailer(name = "test")
        val r2 = Retailer(name by lazy{"test"})
    }
    
    data class Retailer(
            val name: String
    )
    Playground link: https://pl.kotl.in/qfUC7Uzcj
    m
    b
    • 3
    • 5
  • l

    LastExceed

    02/26/2020, 1:32 PM
    question about inheritance: • Using an abstract class or interface i can ensure that every child class has certain functions and fields. • Companion objects can implement interfaces Is there also a way to ensure that child classes have a companion object that implements a certain interface?
    s
    m
    +3
    • 6
    • 9
  • v

    Vinicius Araujo

    02/26/2020, 6:00 PM
    Are scope functions performatic? I mean, is it ok to use them just not to repeat the object's name?
    j
    • 2
    • 1
  • j

    Joan Colmenero

    02/26/2020, 8:23 PM
    is there any way to do something like this :
    interface BaseInterface<F,I> {
    fun example(foo: F, params: I? = null)
    
    }
    I want to add params but as a generic on a method is there any idiomatic way to do it? But I do not want to declare it for every classes that implements this AnInterface
    m
    • 2
    • 4
  • j

    Joan Colmenero

    02/26/2020, 8:32 PM
    Or do I have to do something like this :
    interface BaseInterface<F> {
    fun example(foo:F)
    }
    
    interface Feature1 : BaseInterface<myFoo : Foo> {
    fun example2(myFoo : Foo, param: String) { example(foo) }
    }
    but then can I implement other stuff calling example2?
    z
    c
    • 3
    • 7
  • d

    darkmoon_uk

    02/27/2020, 12:42 PM
    I've been asked a 'challenging' question about our Kotlin adoption at work - that of decompiling. Our products at work are broken down into several binary libraries and some developers, it turns out, are quite reliant on the ability to decompile these in the IDE at Application Debug time. This is not possible out-of-the-box in Android studio. Does anyone have a solution for an ability like the Fernflower decompiler (this is the name of the IDE's Java one), for Kotlin? At this stage it can afford to be 'messier' than the Java one; I'm just looking to offer them an improvement on a 'Can't view compiled code' message.
    s
    d
    +2
    • 5
    • 7
  • l

    Leon K

    02/27/2020, 1:33 PM
    hey! I have a
    Process
    that gives me both
    inputStream
    and
    errorStream
    (
    stdout
    and
    stderr
    respectively), and I need to log the output's of both as soon as they come in. what's the best way to handle that? I guess just doing
    inputStream.bufferedReader().forEachLine {...}
    would block and thus not allow stderr to be handled, thus blocking the process Any ideas?
    s
    d
    • 3
    • 7
  • l

    LastExceed

    02/27/2020, 4:37 PM
    is there a simple way to convert a
    Long
    to
    ByteArray
    ? I found some solutions on StackOverflow ect but they are pretty messy
    b
    • 2
    • 2
  • s

    snowe

    02/27/2020, 5:21 PM
    weird thing is it works perfectly fine in intellij
    n
    p
    • 3
    • 7
  • l

    LastExceed

    02/27/2020, 6:19 PM
    https://hastebin.com/henakilopa.txt how am i supposed to debug something like this? the entire stacktrace is foreign code
    s
    b
    +2
    • 5
    • 18
Powered by Linen
Title
l

LastExceed

02/27/2020, 6:19 PM
https://hastebin.com/henakilopa.txt how am i supposed to debug something like this? the entire stacktrace is foreign code
s

Shawn

02/27/2020, 6:21 PM
😂 3
l

LastExceed

02/27/2020, 6:22 PM
no but seriously, how?
s

Shawn

02/27/2020, 6:23 PM
Dunno how I learned to, but you kinda just do? Start from the top and follow down until you reach your code
b

Brian Dilley

02/27/2020, 6:23 PM
Seems pretty obvious what happened to me
s

Shawn

02/27/2020, 6:23 PM
although in this case, it just looks like the connection was dropped
b

Brian Dilley

02/27/2020, 6:23 PM
While an NIO socket was trying to read data the connection was closed
s

Shawn

02/27/2020, 6:24 PM
https://stackoverflow.com/questions/62929/java-net-socketexception-connection-reset
l

LastExceed

02/27/2020, 6:24 PM
well yeah im working on a game sever and this exception occurs when a player unexpectedly disconnects. i just need to find out where this exception is thrown so i can catch it
b

Brian Dilley

02/27/2020, 6:24 PM
That's really got nothing to do with coroutines anyway That's just how NIO stuff works
➕ 1
l

LastExceed

02/27/2020, 6:24 PM
however the stacktrace doesnt tell me
i thought i already wrapped all the places where i read from the connection in a try/catch, but apparently not
why isnt the stack trace referencing any of my code? i'd expect it to show the line where i try to read from a closed connection
f

FranSoto

02/27/2020, 6:38 PM
because it's an scheduler.
l

LastExceed

02/27/2020, 6:39 PM
which brings me back to my initial question: how do i debug this? do i just randomly put try/catch blocks everywhere until i find the place by chance?
ok turns out i am already catching this exception, but for some reason it is still printed into the console. any way i can prevent that?
b

bezrukov

02/27/2020, 7:48 PM
Most likely CoroutineExceptionHandler prints that exception, you can set your own in your context
l

LastExceed

02/27/2020, 10:19 PM
i tried setting a custom exception handler, but it doesnt trigger. the stacktrace still shows up in the console
b

bezrukov

02/28/2020, 4:59 AM
You probably set it to wrong context/place(it should be in context used in launch fun)🤷‍♂️ show us the code, it will be more helpful
View count: 3