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

    lukas.mega

    03/28/2018, 1:46 PM
    depends
    r
    s
    +3
    8 replies · 6 participants
  • m

    Marcin Wisniowski

    03/28/2018, 3:28 PM
    if ((previous == null) or (previous.type == type)) {
    IntelliJ complains about the dot here, why is
    previous
    not smart-cast to not null if it's checked first?
    d
    6 replies · 2 participants
  • p

    perryprog

    03/28/2018, 3:50 PM
    yeah, I wish they would behave more like threads
    s
    d
    4 replies · 3 participants
  • n

    nish

    03/28/2018, 4:01 PM
    @perryprog can you send me the code snippet you’re trying to pollacode?
    p
    8 replies · 2 participants
  • s

    Shawn

    03/28/2018, 4:13 PM
    you guys might wanna take this to a thread or something, we’re really out of the :kotlin: zone now
    p
    n
    2 replies · 3 participants
  • u

    ursus

    03/28/2018, 7:24 PM
    class Foo {
       Foo(String unhashedPassword) {
           this.hashedPassword = HashUtils.sha1(unhashedPassword)
        }
    }
    c
    4 replies · 2 participants
  • p

    pakoito

    03/28/2018, 11:01 PM
    answering myself, it’s
    hasReceiver()
    and
    receiverType
    . Not
    receiverTypeId
    , which seems to be something unrelated ¯\_(ツ)_/¯
    s
    3 replies · 2 participants
  • j

    jw

    03/29/2018, 2:06 AM
    you also have methods that receive and return these types. that transformation would work for methods which receive these types but not for returning
    m
    8 replies · 2 participants
  • m

    miszmaniac

    03/29/2018, 7:20 AM
    Is there a rule how to name constants outside class scope? ex.
    const val CONFIG_FILE_NAME = "config.json"
    r
    1 reply · 2 participants
  • a

    alex

    03/29/2018, 9:18 AM
    Hi, can you recommend any (maybe Kotlin based) HTTP client library? I am using OkHttp at the moment and gathered experience with Jersey... I am thinking of trying out http://hc.apache.org (Apache HttpComponents) What do you think?
    p
    c
    +1
    37 replies · 4 participants
  • i

    iex

    03/29/2018, 11:43 AM
    is it possible to somehow count the subclasses of a sealed class at runtime?
    r
    a
    3 replies · 3 participants
  • a

    Adrian M

    03/29/2018, 12:53 PM
    Hey guys, how do you isolate singleton tests? I want to check the state of singleton after initialization, but other tests manage to change its state before my initialization test runs. I'm using JUnit 5
    c
    2 replies · 2 participants
  • f

    Fedor Bobin

    03/30/2018, 7:19 AM
    Hello. I am trying to use ktor-clients that use reified generics to handle return type and pass it to deserialization routine.
    httpClient.get<Type>(...): Type <------ return type is handled from reified generic parameter
      
      interface JsonSerializer {
        suspend fun read(type: KClass<*>, content: IncomingContent): Any   <<------ and handled type is used to instantiate object
    }
    If I pass List<MyObject> as a type parameter, I silently get List of garbage because reified generics does not include inner parameters and only List<*> will be passed to JsonSerializer.read(...) I am wonder why not: 1) either: do not allow to pass classes with inner generics to reified methods 2) or: pass something different then just KClass that supports chain of generics
    d
    5 replies · 2 participants
  • m

    mp

    03/30/2018, 10:35 AM
    the case is - that copy is very good for mutation and i want to make some kind of aspect for my pojos with interface so
    interface Archievable {
        val status: ArchievedStatus
    }
    enum class ArchievedStatus { NEW, READY,ARCHIVED}
     ///and then
    data calss User(val blabla, override val status: ArchievedStatus): Archievable 
    data calss Company(val blabla, override val status: ArchievedStatus): Archievable 
    ///with definition of archiving i wan't to create single method that use copy method and work with 2 pojos
    and don't want lose
    copy
    form data class but use it to update entities
    k
    7 replies · 2 participants
  • d

    Daniel

    03/30/2018, 12:40 PM
    Might there be a standard lib function that let's me mix two lists?
    listOf("a", "b", "c") + listOf("d", "e") = listOf("a", "d", "b", "e", c")
    e
    n
    3 replies · 3 participants
  • c

    clubfan

    03/30/2018, 12:41 PM
    maybe zip and then flatmap?
    d
    i
    13 replies · 3 participants
  • a

    ar-g

    03/30/2018, 5:00 PM
    Hi, does anybody know if Kotlin has something similar to p5js https://p5js.org/? The main goal is easy visualization of algorithms.
    p
    g
    16 replies · 3 participants
  • d

    dims

    03/30/2018, 9:26 PM
    may be if I overload invoke operator I will get very close to what I want with parentheses?
    g
    1 reply · 2 participants
  • h

    Hamza

    03/31/2018, 3:30 PM
    hi everyone, I was wondering, how can I get the length of a MutableList? Thanks!
    a
    1 reply · 2 participants
  • h

    Hamza

    03/31/2018, 3:37 PM
    it gave a .size() function, but it's not giving what i wanted 🤔
    s
    1 reply · 2 participants
  • j

    jinbeom hong

    04/01/2018, 3:01 PM
    Are there differences between REPL and source code?:
    // source code
    fun main(args: Array<String>) {
        val value: Int
        value = 3
    }
    // REPL
    >>> val value: Int
    error: property must be initialized or be abstract
    val value: Int
    a
    2 replies · 2 participants
  • s

    Slackbot

    04/01/2018, 10:09 PM
    This message was deleted.
    :stackoverflow: 1
    s
    c
    4 replies · 3 participants
  • r

    ribesg

    04/02/2018, 12:31 AM
    I need confirmation of something not documented anywhere:
    myMutableMap.values.removeAll { <predicate> }
    Will this remove entries from the map?
    a
    h
    3 replies · 3 participants
  • r

    rogerjohns

    04/02/2018, 7:52 AM
    Is there an easy way to run a single junit test?
    g
    14 replies · 2 participants
  • l

    Lilja

    04/02/2018, 10:16 AM
    I have a nullable Int which can be
    null
    ,
    1
    ,
    2
    and so on. It's named
    condition
    . I have a list,
    listOf(1,2,3,4)
    . That's named
    stream
    . Based of on
    condition
    I would like to
    filter
    for
    stream
    , but only if it's non-
    null
    . How can I perform a
    filter
    operation if a condition either is
    null
    or a value?
    if(condition != null) stream.filter(it == condition) else stream
    is one solution I suppose but is there a cleaner way?
    a
    1 reply · 2 participants
  • n

    nil2l

    04/02/2018, 10:19 AM
    stream.filter { condition == null || it == condition }
    👍 1
    a
    4 replies · 2 participants
  • t

    tipsy

    04/02/2018, 11:05 AM
    is there a simple way to go through a range in parallel ?
    2 replies · 1 participant
  • n

    ndkoval

    04/02/2018, 1:10 PM
    Hi! Has anyone tried to build Gradle/Maven Kotlin project using a custom hotspot build? When I am trying to do this with a custom JDK10 build, it fails with
    No class roots are found in the JDK path: /home/nkoval/jdk10-consol-proto/build/linux-x86_64-normal-server-release/jdk
    I run it on Ubuntu and for Java projects it works well.
    2 replies · 1 participant
  • c

    Clayton Walker

    04/02/2018, 10:04 PM
    not worth it for the problem we're trying to solve. we were wondering because the last comment on https://youtrack.jetbrains.com/issue/KT-8889 made it seem like end users had access, all warnings aside.
    g
    d
    2 replies · 3 participants
  • c

    Clayton Walker

    04/02/2018, 10:12 PM
    that would have been fine for our case, it would have been a tweaked version of the string extension example i listed above.
    g
    1 reply · 2 participants
Powered by Linen
Title
c

Clayton Walker

04/02/2018, 10:12 PM
that would have been fine for our case, it would have been a tweaked version of the string extension example i listed above.
g

gildor

04/02/2018, 11:49 PM
Why do you need this? I mean yeah, this is helpful feature, but is it really worth to use experimental language features not even released and enable future version of language that can be unstable or contains critical bugs? Because there are no cases where contracts are required to write correct code.
View count: 2