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

    pawel.rybicki

    09/03/2019, 3:55 PM
    (once again sry for how this issue is presented)
    s
    e
    • 3
    • 10
  • r

    Rafa

    09/03/2019, 11:55 PM
    Playing around with generics in Kotlin, and thought this was interesting
    class Example<T>(private val source: T){
        fun test(value: T?): T? = value
    }
    
    fun <T> create() = Example(null)
    If we define the class to take in a non-nullable generic type, and still pass in null,
    Example(null)
    then the generic resolves to
    Example<Nothing?>
    . If we make the generic nullable
    T?
    then it resolves to
    Example<Nothing>
    . I can't find anything online that confirms that null on a generic type returns "Nothing" and I guess it kind of make sense, but can anyone confirm as to how that happens?
    s
    p
    • 3
    • 4
  • q

    qasim majeed

    09/04/2019, 7:45 AM
    what is ? for in this statement val x: String? = “foo”
    g
    • 2
    • 2
  • s

    Saurav Kothari

    09/04/2019, 8:02 AM
    I just posted this question on SO - https://stackoverflow.com/questions/57783848/kotlinmapper-to-map-sql-date-to-kotlin-date I am trying to use
    KotlinMapper
    to cast an SQL
    Date
    column to Kotlin
    Date
    . Would appreciate any help I can get!
    g
    • 2
    • 4
  • j

    Jakub

    09/04/2019, 9:36 AM
    I have listener defined as lambda
    var listener: (()->Unit)? = null
    . In kotlin I would pass it like
    mCircleShape.listener = {}
    but how to pass it from
    Java
    ?
    w
    • 2
    • 3
  • s

    Slackbot

    09/04/2019, 9:44 AM
    This message was deleted.
    t
    • 2
    • 1
  • l

    LastExceed

    09/04/2019, 10:59 AM
    runBlocking {
            try {
                val listener = aSocket(ActorSelectorManager(<http://Dispatchers.IO|Dispatchers.IO>)).tcp().bind(InetSocketAddress(12345))
                val socket = listener.accept()
                println("client connected")
                socket.openReadChannel().readInt()
            }
            catch (ex: Throwable) {
                println("client disconnected")
            }
        }
    when i connect to this and then disconnect it throws a `CancellationException`which is caused by an
    IOException
    . More specifically, it is thrown in
    readInt()
    because it's trying to read data from a closed stream. I know i can and should only catch that specific exception at that specific line, but for the example code i wrapped the entire thing in catch Throwable to make double sure it catches everything. But even though I catch it and the catch block is executed just fine the exception is still thrown into the console. why is that?
    s
    • 2
    • 5
  • a

    asad.awadia

    09/05/2019, 1:57 AM
    Do you think kotlin will break out from the java interop thing and become a cloud native language on its own. Maybe improving upon the memory consumption or need for jvm
    🇳🇴 5
    p
    s
    +2
    • 5
    • 4
  • s

    ShootingStar

    09/05/2019, 8:17 AM
    however current version of kotlin 1.3. There is no expectedBy
    g
    b
    • 3
    • 57
  • c

    coder82

    09/05/2019, 10:00 AM
    It would be nice if IDE would know it's a conflated channel and not put the suspend arrow indicator when calling send() on it... maybe it was better a specific type than an initialization parameter
    g
    m
    • 3
    • 13
  • a

    Adrian M

    09/05/2019, 12:38 PM
    hi, has anyone of you guys made a comparison of functional aspects of Java+Vavr vs. Kotlin? What are your feelings? Or is Kotlin and Vavr complementing each other?
    a
    d
    k
    • 4
    • 3
  • d

    dgleeson

    09/05/2019, 7:05 PM
    I'm trying to use Guice injection for my kotlin project. I'm declaring stuff like
    class KotlinWebService @Inject constructor(configuration: KotlinServiceConfiguration) : WebService(configuration.webServerPort, configuration.oidcBaseUrl)
    that has mostly been working as expected. The problem I have is when I try to do something to the super during the init. e.g.
    init { super.setUnauthorizedUrls(setOf("/path")) }
    I get
    java.lang.UnsupportedOperationException
    . It seems like init is happening before injection. Does anyone have any ideas?
    c
    • 2
    • 5
  • t

    Toddobryan

    09/06/2019, 12:06 AM
    As of very recently, running Optimize Imports in IntelliJ starts inserting imports for things like
    kotlin.String
    ,
    <http://kotlin.to|kotlin.to>
    , and
    kotlin.with
    that should not need to be imported. Both my colleague and I are noticing this . Is it just us and is there a way to stop this madness?
    l
    • 2
    • 2
  • j

    jmfayard

    09/06/2019, 7:42 AM
    If I have a java library that defines
    SomeImportantApiClass.java
    , is it possible to declare in java a empty
    Companion
    object so that Kotlin users of the library can define their extension on
    fun SomeImportantApiClass.Companion.someExtension()
    ?
    w
    • 2
    • 1
  • m

    Mahendran

    09/06/2019, 10:25 AM
    Kotlin interface to lambda? (Any Trick)
    c
    s
    +2
    • 5
    • 6
  • j

    jfburdet

    09/06/2019, 2:35 PM
    Hi folks, I'm using kotlin with intellij and gradle, and have weird problem : I can access (build+run) java.io.InputStream.readAllBytes() in the IDE, but when running the project with gradle, i'm getting an "Unresolved reference: readAllBytes" readAllBytes seems included in Java12 but not in Java1.8 ... Any quick hint ? I can provide a sample project to reproduce that ...
    u
    c
    • 3
    • 10
  • s

    Sam Schilling

    09/06/2019, 4:29 PM
    Has anyone else experienced issues with Kotlin/Native not deallocating NSObjects?
    r
    • 2
    • 3
  • g

    Gopal S Akshintala

    09/07/2019, 3:02 PM
    Kotlin Ranges: Why isn't there a
    downTo
    variant to exclude last item like
    until
    ?
    g
    • 2
    • 2
  • k

    karelpeeters

    09/08/2019, 6:37 PM
    Why are nullable function parameters not allowed on an inline function? Eg this gives an error:
    inline fun foo(block: (() -> Unit)?) {
        block?.invoke()
    }
    Inline parameter [...] must not be nullable. Add 'noinline' modifier to the parameter declaration or make its type not nullable
    Why? Would there be a problem compiling something like that? I can't imagine why. Interestingly you can suppress this,
    @Suppress("NULLABLE_INLINE_PARAMETER")
    but that does't actually inline the lambda, and the IDE doesn't suggest that.
    a
    r
    • 3
    • 8
  • p

    PHondogo

    09/09/2019, 8:15 AM
    Hi! I have code like this:
    fun <T> test(v: T, lambda: (T) -> Unit ) {
      lambda(v)
    }
    And at call site i have code :
    val lambda = {v : Any -> println(v)}
    test<SomeObject>(SomeObject(), lambda)
    The code below wont compile, cause compiler want to have my val lambda have parameter type exact as declared in function. How should I modify my fun test declaration to allow <in Parameter> in lambda parameter?
    r
    • 2
    • 5
  • a

    alexey.sedunov

    09/09/2019, 10:11 AM
    Hi! Is there anyone interested in being a reviewer for a new Kotlin book by BPB Publications? 🙂 Please ping me privately or in this thread
    l
    a
    • 3
    • 6
  • m

    Mark Buikema

    09/09/2019, 10:16 AM
    when using
    groupBy
    , is there any nice and easy way to sort the items within the groups?
    g
    • 2
    • 2
  • b

    BugsBunny

    09/09/2019, 1:05 PM
    Is there any channel to ask really basic doubts amongst beginners? I have just started using Kotlin!
    s
    • 2
    • 1
  • j

    Juanoterocas

    09/09/2019, 10:14 PM
    in java i can do:
    if(x!=null && x.name.equals("name"))
    {}
    first evaluate if x is not null then second condition, second condition is not checked if x is null and then is false since && operator only true when all its true, must stop evaluating second condition, is this by desing? how could I do this in kotlin?
    d
    s
    +2
    • 5
    • 13
  • m

    Mahendran

    09/10/2019, 6:39 AM
    Java ExecutorService Alternative in kotlin?
    :google: 1
    s
    g
    • 3
    • 2
  • d

    Daniele Segato

    09/10/2019, 9:44 AM
    EDIT: nevermind, I'm an idiot, used the setter
    field
    , of course he force me to initialize Why does the compiler force me to initialize a variable that is never actually read? the
    get()
    doesn't ever expose the actual value of
    entries
    but if I do not include
    = null
    it complain with
    property must be initialized
    I might be wrong but I kinda remember it didn't worked like that a couple of months ago (previous versions)
    variable-example.kt
    w
    • 2
    • 4
  • m

    Mahendran

    09/10/2019, 10:56 AM
    wait() notify () method in Kotlin
    :kotlin: 1
    :google: 2
    g
    c
    • 3
    • 3
  • j

    janvladimirmostert

    09/10/2019, 10:59 AM
    is Kotlin supported on GraalVM ? or can i assume it'll just work due to Java compatibility ?
    :yes: 5
    m
    d
    • 3
    • 4
  • c

    coder82

    09/10/2019, 1:06 PM
    is there a way to define handleStopRequest using fun? as if it was a normal extention function, but defined within the object, I couldn't figure out a way
    Untitled
    w
    • 2
    • 5
  • n

    nimtiazm

    09/10/2019, 2:15 PM
    what to replace ? with in kotlin when we don’t know what will type be at runtime and it’s definition isn’t gonna participate in any method signature of this interface
    a
    k
    r
    • 4
    • 14
Powered by Linen
Title
n

nimtiazm

09/10/2019, 2:15 PM
what to replace ? with in kotlin when we don’t know what will type be at runtime and it’s definition isn’t gonna participate in any method signature of this interface
a

adamd

09/10/2019, 3:30 PM
have you tried
Any
?
n

nimtiazm

09/10/2019, 3:49 PM
yes it’s a recursive bound. to keep it open I use ? in java
using Any is similar to using star projection. so it doens’t work
T and U are simply input and output in one CStage and U is input in another CStage where output is unknown
actually in the interface, the method signatures utilize T, U and N only so it works out nicely
yes
It has to be this way because U (output) from first CStage replaces T (input) in second CStage
i’m using it without any problem.
if i use
CStage<T, U, N: CStage<U, *, N>>
i can’t use any other CStage for N
k

Kroppeb

09/10/2019, 8:32 PM
@Ruckus T and U aren't bound together though?
n

nimtiazm

09/11/2019, 7:44 AM
no there are no bounds for T and U
only N is recursively bound because it has to implement CStage
k

Kroppeb

09/11/2019, 8:35 AM
lol did he delete all his msgs?
r

Ruckus

09/11/2019, 3:23 PM
@Kroppeb Yes, I did. Sorry about that. I was getting frustrated with the conversation and didn't want to get any more notifications for it. I was operating under the false impression that deleting my comments would unsubscribe me from this thread. On the bright side, I have now discovered the (very large and obvious) "Unfollow thread" action.
View count: 1