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

    Benjamin Charais

    04/01/2019, 8:23 PM
    I went back through the channel directory and without searching hiring, it doesn’t seem to show in the list.
    p
    h
    • 3
    • 3
  • j

    Jakub Aniola

    04/02/2019, 12:49 PM
    How to compile Kotlin using CLI and include java .jar with it? I compile kotlinc cli standard way:
    kotlinc main.kt -include-runtime -d main.jar
    And execute
    java -jar main.jar args
    But how to include another jar in it? I am using kotlinx.coroutines and I want to using it while compiling in cli
    c
    • 2
    • 4
  • v

    Venaseph

    04/02/2019, 1:33 PM
    Just wondering if anyone has a suggestion for a Jazzy type documentation generator in Android land
    :google: 1
    r
    c
    • 3
    • 11
  • b

    bbaldino

    04/02/2019, 4:40 PM
    i've been playing with inline classes and noticed when doing some CPU profiling i was spending some time in what seems to be an init method of my inline class. i thought they'd just be compiled to the underlying type?
    RtpSequenceNumber
    is my inline class here, it wraps an
    Int
    h
    • 2
    • 24
  • g

    GarouDan

    04/02/2019, 5:29 PM
    Try to use ::class.java.isAssignableFrom() or javaClass.isAssignableFrom
    r
    • 2
    • 2
  • l

    LeoColman

    04/02/2019, 5:30 PM
    I don't want to use javaClass, as this is for a MPP projet (no JVM)
    g
    • 2
    • 1
  • d

    Dico

    04/02/2019, 5:32 PM
    If a Java functional interface has its type parameter used invariantly, but it can't declare it as intravariant, how can I make a class that implements it with the type parameter in invariant position? Expanded in a thread with code.
    p
    • 2
    • 6
  • p

    pavel

    04/02/2019, 7:19 PM
    the last example uses transform
    r
    s
    • 3
    • 2
  • s

    Smallville7123

    04/02/2019, 11:08 PM
    how do i create a @sample which is not of kotlin code, as if i use /**/ the block comments themselves will be visible in the sample which i do not want
    m
    • 2
    • 1
  • a

    Alexjok

    04/03/2019, 11:34 AM
    Hello, how i can do something like that:
    inline fun <reified T>  execute(): T {
       
        return doRequest()
    }
    
    private  inline fun <reified T> doRequest(): T
    {
       //doSomething
    }
    Get the error "Public API inline function cannot access non public API" How to solve it?
    d
    j
    l
    • 4
    • 13
  • s

    spand

    04/03/2019, 1:59 PM
    If I have multiple version of ie. guava on the classpath (its a gradle project), shouldnt IDEA order them by version in descending order when running from inside IDEA? Or is it undefined ?
    h
    • 2
    • 5
  • e

    ec

    04/03/2019, 2:54 PM
    Would you use Kotlin Channels in prod even though they are marked experimental?
    s
    s
    +3
    • 6
    • 9
  • e

    ec

    04/03/2019, 4:28 PM
    Whats your choice of "micro"framework would be for simple app? http4k/ktor/vertx/micronaut all seems solid choices with kotlin support, I'm confused
    c
    • 2
    • 1
  • b

    bogdoll

    04/03/2019, 6:00 PM
    If you are required to work with ThreadLocals, would that be a good idea or not:
    class ThreadlocalDelegate<E>(initializer: ()->E) {
        private val threadLocal = ThreadLocal.withInitial(initializer)
    
        operator fun getValue(thisRef: Any?, property: KProperty<*>): E {
            return threadLocal.get()
        }
    
        operator fun setValue(thisRef: Any?, property: KProperty<*>, value: E) {
            threadLocal.set(value)
        }
    }
    
    fun <E> threadlocal(initializer: ()->E) = ThreadlocalDelegate(initializer)
    
    fun main() {
    
        val sdf by threadlocal { SimpleDateFormat("yyyy-MM-dd HH:mm:ss").apply {
            timeZone = TimeZone.getTimeZone("UTC")
        }}
    
        for(i in 0 until 10 ) {
            thread {
                println("${Thread.currentThread().name} - ${System.identityHashCode(sdf)}) - ${sdf.format(Date())}")
            }
        }
    
    }
    k
    c
    +2
    • 5
    • 11
  • s

    s1m0nw1

    04/03/2019, 7:27 PM
    can inline classes be properly observed with the Kotlin Bytecode tool? It shows that my inline class is actually compiled to a regular class which seems wrong
    h
    • 2
    • 1
  • m

    mvbrenes

    04/03/2019, 9:55 PM
    Im sure many of my peers on this channel may use `Bitbucket`™ or have in the past. I’ve noticed that Kotlin syntax highlighting is missing from when reviewing
    .kt
    files unless you go into edit mode. I’m not sure how they prioritize their own issues but this one has been opened since June, maybe if we all go an upvote it they may get around to resolving this annoyance. https://bitbucket.org/site/master/issues/16513/kotlin-syntax-highlighting-not-working
    s
    m
    • 3
    • 8
  • j

    jiangxingbing

    04/04/2019, 6:55 AM
    Hi everyone! Is it possible to add @JvmOverloads to the generated copy(…) method in Kotlin?
    🇳🇴 1
    g
    • 2
    • 2
  • r

    ribesg

    04/04/2019, 9:51 AM
    Can I get the receiver type name from a
    KProperty1<*, *>
    ?
    d
    • 2
    • 12
  • a

    Artglorin

    04/04/2019, 2:12 PM
    Hello! I have problem with Kotlin type inference. Please help me solve it if it possible.
    r
    h
    • 3
    • 6
  • l

    Luke

    04/04/2019, 2:53 PM
    Is there a method in the standard library to shorten this code?
    items.forEach {
        it.apply {
            ...
        }
    }
    t
    • 2
    • 2
  • d

    david-wg2

    04/04/2019, 2:53 PM
    items.onEach
    ?
    l
    d
    +3
    • 6
    • 11
  • e

    Erik Colban

    04/04/2019, 6:03 PM
    I've just joined the Slack channel. Hello to you all. I've been working for a couples of days trying to implement something similar to Python decorators in Kotlin. I've created a Github repository [here](https://github.com/ecolban/FunctionDecorators). The README file provides details of what I've achieved so far, and what I'd like to achieve. I'm open to suggestions.
    b
    m
    • 3
    • 16
  • l

    LeoColman

    04/05/2019, 4:46 AM
    Is it possible to "Reset" an object in a test?
    a
    g
    +3
    • 6
    • 17
  • g

    ghosalmartin

    04/05/2019, 9:55 AM
    how do I differentiate?
    d
    • 2
    • 4
  • b

    Bruno_

    04/05/2019, 11:37 AM
    in spring, should there always be a layer between controllers and repositories? what do you think?
    x
    s
    • 3
    • 4
  • a

    amadeu01

    04/05/2019, 12:03 PM
    but, the
    Companion object
    does not exist on
    T
    d
    r
    • 3
    • 3
  • p

    pablisco

    04/05/2019, 4:26 PM
    Yea or Nay? Thoughts? https://twitter.com/pablisc0/status/1114196626002698240
    👍 7
    🇳🇴 5
    l
    i
    +4
    • 7
    • 17
  • h

    hudsonb

    04/05/2019, 5:03 PM
    Should one include
    companion object {}
    in library classes to support extension?
    s
    c
    +4
    • 7
    • 16
  • a

    Andrew Gazelka

    04/05/2019, 7:21 PM
    I'm so confused... maybe this is an IntelliJ bug but the first suspending breakpoint only goes off once per cycle (same with
    println("A")
    .... however the non-suspending logging breakpoints each log TWICE per cycle (so in total the two breakpoints log FOUR times per cycle)...
    a
    • 2
    • 1
  • j

    joeamrhein

    04/05/2019, 8:14 PM
    is there a function similar to
    map
    that skips over an item if it doesn't satisfy a conditional statement? For example:
    data class Foo(val nullableName: String?)
    data class Bar(val nonNullName: String)
    
    val list: List<Foo> = fetchList()
    list.map { item ->
      if (item.nullableName != null) {
          Bar(item.nullableName)
      }
    }
    k
    a
    z
    • 4
    • 4
Powered by Linen
Title
j

joeamrhein

04/05/2019, 8:14 PM
is there a function similar to
map
that skips over an item if it doesn't satisfy a conditional statement? For example:
data class Foo(val nullableName: String?)
data class Bar(val nonNullName: String)

val list: List<Foo> = fetchList()
list.map { item ->
  if (item.nullableName != null) {
      Bar(item.nullableName)
  }
}
k

Kirill Zhukov

04/05/2019, 8:14 PM
You could filter first and then map
a

Alowaniak

04/05/2019, 8:16 PM
or
list.mapNonNull {
  if (it.nullableName == null) null
  else Bar(item.nullableName)
}
j

joeamrhein

04/05/2019, 8:16 PM
thanks!
z

zokipirlo

04/08/2019, 7:53 AM
It's `mapNotNull`not
mapNonNull
. You get also IntelliJ hint 🙂
View count: 10