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

    amadeu01

    03/01/2019, 12:54 PM
    hi guys, I'm trying to use https://play.kotlinlang.org with com
    -Xallow-result-return-type
    but seems not work with the play.kotlin. Has anyone tried it before?
    i
    • 2
    • 2
  • a

    amadeu01

    03/01/2019, 12:56 PM
    But, I do not know whether that should work or not.
    p
    • 2
    • 1
  • e

    elect

    03/01/2019, 1:18 PM
    according to this answer (https://stackoverflow.com/questions/39679180/kotlin-call-java-method-with-classt-argument) by @apatrida:
    The error message could be clearer to say "only classes without generic parameters are allowed on the left side of ::"
    ArrayList<*>::class
    changes nothing though
    p
    • 2
    • 4
  • e

    elect

    03/01/2019, 1:19 PM
    this doesnt explain why
    Array<VkCommandBuffer>::class
    works flawless
    k
    d
    • 3
    • 15
  • g

    gavvvr

    03/01/2019, 3:39 PM
    Hello. How do you quickly create unit-test for a given class using Kotlin? The problem is that IDE generates file with
    java
    extension in kotlin source root. Same for Groovy
    a
    • 2
    • 1
  • f

    fred.deschenes

    03/01/2019, 4:04 PM
    is there any way to bypass using a built-in infix function for a specific statement (ie: I'm using a library that has a "to" function and it's always using Kotlin's "to" to create a Pair)?
    p
    l
    • 3
    • 8
  • l

    laimiux

    03/01/2019, 6:41 PM
    Is there a lint check to prevent not invoking a lambda such as doing
    onClick
    instead of
    onClick()
    when
    val onClick: () -> Unit
    ?
    r
    l
    • 3
    • 13
  • d

    dimsuz

    03/01/2019, 8:00 PM
    Kotlin styleguide recommends to cut that to
    src/main/main.kt
    . I'm talking about this. Cited this part in linked post above
    :thread-please: 2
    👌 1
    s
    i
    • 3
    • 6
  • d

    drofwarcs

    03/01/2019, 8:51 PM
    Running into a kotlin/Java snafu. Received a library written in Kotlin, and the app thats going to use the library is all in Java and there is no plan to introduce Kotlin to that app....yet. The Kotlin library has a public api similar to
    fun doBar(callBack: (String, Array<Int>) -> Unit)
    . That gets exposed to Java as
    doBar(Function2<? super String, ? super Integer[], Unit> callback)
    . When ever we try to create a anonymous class of Function2 we get
    doBar(Function2<? super String, ? super Integer[], Unit> callback) cannot be applied to (anonymous Function2< String, Integer[], Unit>)
    . Is there another way to call a kotlin function interface from Java?
    c
    • 2
    • 6
  • k

    kd

    03/01/2019, 9:21 PM
    How do you create a copy of a List, that changes references but keeps the objects? I have tried
    toList
    method but it does not seem to work. Context: I am trying to implement a simple recycler view and update it using DiffUtil, but the oldList and newList are the same for some reason
    k
    n
    • 3
    • 3
  • o

    obobo

    03/01/2019, 10:03 PM
    Hello, I've run into a situation and I've been trying to figure it out. I have an extension function declared at the top level in my module, and I have an extension function declared within a class' scope. When I call a method that changes the receiver to this scope, I can't figure out how to access the top-level function. An example:
    fun MyObject.get(str: String): String {
            return get(str) {}
        }
    
    class Scope {
            operator fun Any.get(str: String): Int = 1
    }
    
    // within method body
    val myObject = MyObject()
    val scope = Scope()
    
    with(scope) {
      myObject.get("abc") // calls Scope's get()
    }
    How do I tell the compiler to call MyObject.get()? Suppose that both extension functions are define din libraries, so I can't easily change those names.
    c
    • 2
    • 7
  • a

    Andrew Gazelka

    03/02/2019, 12:42 AM
    is it just me or is
    assert
    dead? From what I see on Google it isn't even enabled by default in junit unit tests afaik
    n
    • 2
    • 1
  • a

    aoriani

    03/02/2019, 1:03 AM
    Could you give an example?
    a
    • 2
    • 1
  • q

    Quang Luong

    03/02/2019, 12:19 PM
    Hi, I am playing with GraalVM APIs and realize the polyglot API cannot change Kotlin class members' values, while it can in Java. Why does this happen ??
    java
    import org.graalvm.polyglot.Context;
    class Scratch {
      public class Response {
        public int x = 2;
      }
      void run () {
        Context context = Context.create();
        Response r = new Response();
        context.getBindings("js").putMember("r", r);
        context.eval("js", "r.x = 42");
        System.out.println(r.x); // print 42
    
      }
      public static void main(String[] args) {
        new Scratch().run();
      }
    }
    Different_behavior_between_Java___Kotlin_.kt
    g
    • 2
    • 2
  • j

    Jakub Aniola

    03/02/2019, 12:51 PM
    How to pass arguments to the kotlin command line? I cannot find example (https://kotlinlang.org/docs/tutorials/command-line.html) Same as in Java: java exampleClass 5000 java exampleClass 0 < input.txt
    k
    r
    i
    • 4
    • 8
  • a

    Andrew Gazelka

    03/03/2019, 7:15 PM
    are delegates a bad practice if they break encapsulation by requiring a public API?
    k
    • 2
    • 2
  • h

    Hullaballoonatic

    03/03/2019, 8:43 PM
    Due to its extensions and overall syntax philosophy, kotlin is the only language where i feel i can consistently write functions in the form of
    subject.verb(object)
    . I personally hate syntax like python's
    len(list)
    , because I feel like as a property of the list, it should be called as
    list.len
    , and that
    len(list)
    implies some kind of transformation of
    list
    s
    y
    • 3
    • 9
  • c

    CRamsan

    03/04/2019, 3:29 AM
    Hello eveyone, I had a question with how to approach unit testing. Right now I am working on a small multiplatform library with 98% of the code in the common source set with the rest being some platform-specific implementations in jvm and native. I have all the unit tests in the common-test source-set but now I need some add some junit unit tests for code that will trigger coroutines. The recommendations online to handle coroutines in UT is to wrap them in runBlocking, but this is only available in native/JVM. Is there any other way to have my Unit Tests remain in the common package while also calling into coroutines?
    j
    • 2
    • 2
  • d

    damian

    03/04/2019, 12:45 PM
    Does anyone know why
    MyClass::class.simpleName
    is of
    String?
    type? Why is it not
    String
    ?
    s
    h
    +2
    • 5
    • 6
  • u

    user

    03/04/2019, 3:10 PM
    message has been deleted
    :kotlin: 22
    🎉 16
    🎂 9
    3️⃣ 1
    ❤️ 4
    k
    • 1
    • 1
  • l

    LeoColman

    03/04/2019, 6:34 PM
    Hi, how to obtain all functions that have a functional parameter using Kotlin Reflect? I tried something like
    Class.forName("myClass").declaredMethods.map { it.kotlinFunction!! }.filter { fn -> fn.parameters.any { it is KFunction<*> } }
    but it didn't work
    f
    • 2
    • 14
  • e

    elect

    03/04/2019, 6:43 PM
    why I dont have any
    associatedWithTo
    on
    Enum.values()
    (
    Array<T>
    )? https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/associate-with-to.html
    f
    p
    • 3
    • 3
  • k

    Kris Elsinga

    03/04/2019, 7:42 PM
    Hey, i'm new here. the above snippet is for my question. I create a client from an api, and it has a getIdleTimer function. I want to check the idleTime every x seconds, and then do something when a certain time has passed. so I implemented the coroutinescope on the client, and made the snippet so it checks every x time. my question is, do I have to save the coroutine and fixedrate time in a variable that I'll probably never touch again?
    d
    • 2
    • 1
  • d

    Davide Giuseppe Farella

    03/05/2019, 2:59 AM
    What could be a good way for provide a compile time - type safety on
    Any
    ? Let’s say that I got this class and I want the better way for ensure that
    image
    is
    Drawable, Int, Bitmap, File, String or Uri
    and placeholder is
    Drawable, Int, Bitmap or File
    without crashing at runtime
    l
    s
    +3
    • 6
    • 16
  • r

    René

    03/05/2019, 7:47 AM
    Hey guys, I run into trouble while publishing a project. I am not absolutely sure, but I guess I found a bug in the kotlin gradle plugin. For some strange reasons there is a "maven" publication from nowhere. I think the kotlin plugin might create that one. For now I just found a reference in MPP, but I think there is also something for "normal" projects. Is there someone familiar with the gradle plugin? I already opened a bug on a differnt project for more details check this link: https://github.com/novoda/bintray-release/issues/266
    k
    m
    t
    • 4
    • 9
  • o

    Oscar Torreno

    03/05/2019, 9:40 AM
    Hey guys, I have the following scenario: I want to send a lambda/function to a different thread defined in a different module too. Both threads (sender and receiver) have a common dependency where the lambdas/functions are defined. However when I serialize the lambda to a byte array in line number 17, ::toLong is not referencing the definition of such function in Lambdas.kt but something like Main$1$… what makes module C not being able to deserialize it because is not able to find the class Main$1$… since it does not have the dependency. Why is it ::toLong not referencing the definition contained in Lambdas.kt of module A?
    Serializing_lambdas_functions.txt
    d
    • 2
    • 2
  • s

    Slackbot

    03/05/2019, 2:11 PM
    This message was deleted.
    g
    m
    • 3
    • 3
  • p

    Paul Woitaschek

    03/05/2019, 2:48 PM
    I need some compilation safety for the following scenario: I want to create a specific object for each type of a sealed class. Is that somehow possible?
    d
    • 2
    • 1
  • e

    efemoney

    03/05/2019, 3:04 PM
    My current idea is to showcase how kotlinlang improves implementation of and, in some cases, obsoletes some of Effective Java’s recommendations
    h
    p
    +4
    • 7
    • 12
  • m

    Matthew Hall

    03/05/2019, 5:06 PM
    Where's the best place to ask a question about Kotlin-Java interop, specifically for java.util Collections vs kotlin.collections?
    k
    • 2
    • 3
Powered by Linen
Title
m

Matthew Hall

03/05/2019, 5:06 PM
Where's the best place to ask a question about Kotlin-Java interop, specifically for java.util Collections vs kotlin.collections?
k

karelpeeters

03/05/2019, 5:19 PM
This channel or #getting-started depending on how "basic" the question is.
Or maybe #stdlib if it's about the extension functions on collections.
m

Matthew Hall

03/05/2019, 5:37 PM
Thanks
View count: 2