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

    hallvard

    10/30/2019, 3:07 PM
    Does a combination of
    data class
    and builder pattern exist, or is it even possible? I'd like the simplicity of a data class, but with setters that return
    this
    ... Anyone?
    s
    d
    +2
    • 5
    • 16
  • t

    Travis Griggs

    10/30/2019, 6:31 PM
    I’m tired of being told that I can’t compare
    someByte == 13u
    . Is it possible to implement an unbalanced equals override that will let me compare these without having to put toUByte() or toUInt() in everywhere. I tried something like: fun UInt.equals(b:UByte) : Boolean { return this == b.toUInt() } (and the reverse as well) But == sites still complain
    d
    k
    • 3
    • 3
  • m

    magisu

    10/30/2019, 10:32 PM
    Is there a way I could solve this issue?
    c
    d
    • 3
    • 6
  • m

    magisu

    10/30/2019, 10:32 PM
    Cause in Kotlin there is no point to write event.eventSource == null test, as at Kotlin level the event.eventSource will always be non-null
    k
    a
    • 3
    • 8
  • x

    xenoterracide

    10/31/2019, 7:06 AM
    if I set java 11 as the target of kotlin, will java files also be able to use things like
    var
    (from java 10)?
    g
    a
    • 3
    • 12
  • j

    James

    10/31/2019, 9:15 AM
    https://stackoverflow.com/questions/58588775/using-android-library-in-kotlin-multiplatform-library
    a
    • 2
    • 1
  • a

    Animesh Sahu

    10/31/2019, 10:21 AM
    Can anyone solve issue in #ktor i asked around 4 hours ago still no response...
    k
    • 2
    • 1
  • g

    gianluz

    10/31/2019, 10:24 AM
    any idea when kotlin 1.3.60 will be released officially?
    s
    g
    • 3
    • 4
  • b

    Bikram

    10/31/2019, 11:07 AM
    Why every class in kotlin by default "final"?
    f
    m
    s
    • 4
    • 5
  • j

    Jérôme Gully

    10/31/2019, 12:35 PM
    Hi, I plan to participate to the Github annual Game Jam, and with my team we want to try Kotlin multi-platform to make the game running on Android, iOS and Web. Can I create and code the project into Android Studio or I need to use Intellij ? Also, if you have heard of some people who have do some little games with Kotlin multi-platform, I'm interested.
    👀 2
    l
    • 2
    • 2
  • j

    jeggy

    10/31/2019, 1:19 PM
    Could someone help me find the source code of hashCode for data classes in Kotlin?
    k
    d
    a
    • 4
    • 22
  • y

    Yan Pujante

    10/31/2019, 2:37 PM
    Seems like a silly question, but where can I find what is the latest version of kotlin and release notes? https://kotlinlang.org/ says "Kotlin 1.3 Released" and is a link to release notes but that is not exactly the latest version (seems like there is a 1.3.50... but where can I find this info with release notes)?
    r
    j
    +2
    • 5
    • 7
  • m

    Martin Nordholts

    10/31/2019, 3:19 PM
    Why is this not allowed?
    val map: Map<String, Int>? = mutableMapOf("one" to 3)
            map?.["one"] // <- Why is this not allowed?
            map?.get("one") // <- Which is equivalent to this, which works
    s
    m
    +2
    • 5
    • 7
  • h

    Hullaballoonatic

    10/31/2019, 6:21 PM
    anyone ever wish there was a clean way to do
    else ""
    ,
    else 0
    , etc?:
    return myStr + if (myCondition) myPostfix else ""
    return myVal + if (myCondition) myAddition else 0
    obviously the nicest syntax would probably simple exclude the
    else
    , but that of course does not compile
    k
    d
    +3
    • 6
    • 16
  • p

    pavel

    10/31/2019, 9:29 PM
    I have a
    List<Pair<A,B?>>
    Is there an easy way to filter out all where
    second==null
    and make the type be
    List<Pair<A,B>>
    ?
    k
    b
    • 3
    • 10
  • a

    alwyn

    10/31/2019, 9:53 PM
    Anyone know why:
    val t = '\u223C'  // TILDE
    val a = "A" + t + "B" + t + "C"
    val b = "A~B~C"
    val c = "A${t}B${t}C"
    println (a == b)    // false
    println (b == c)    // true
    ?
    p
    m
    • 3
    • 10
  • a

    Alex Kuznetsov

    10/31/2019, 10:20 PM
    Which libraries have the following: 1. Trees, B-Trees, Black/Red Trees, traversing them leafs first and root first. Balanced search trees and rebalancing. 2. All permutations (same as CROSS JOIN in SQL)
    k
    • 2
    • 4
  • a

    Anastasia Finogenova

    11/01/2019, 2:42 AM
    Hey, at what point is the value converted to Int in Kotlin? AS is showing a warning that Byte is expected but found Int even though in the Java version of the code it is picked up as byte. Kotlin: var r = byteArray[3 + i] If (r > 0) r += 255 //the warning is shown here Java: byte r = byteArray[3 + i] If (r > 0) r += 255; //the warning is not shown
    g
    s
    • 3
    • 3
  • v

    Vishnu Haridas

    11/01/2019, 2:08 PM
    This is a question on Type Inference that I posted on StackOverflow. First guess the answer and then look at the SO answer. I understand that Kotlin is a statically-typed language, and all the types are defined/inferred at the compile time itself. Here is a
    when
    expression that returns different types:
    fun main(){
    
            val x = readLine()?.toInt() ?: 0
    
            val y = when(x){
                1 -> 42
                2 -> "Hello"
                else -> 3.14F
            }
    
            println(y::class.java)
    }
    During runtime (Kotlin 1.3.41 on JVM 1.8) this is the output: When
    x
    = 1, it prints
    class java.lang.Integer
    When
    x
    = 2, it prints
    class java.lang.String
    Otherwise, it prints
    class java.lang.Float
    When does the compiler determine the type of
    y
    ? Or, how does the compiler infers the type of
    y
    during compile-time? Question on StackOverflow: https://stackoverflow.com/q/58479824/816416
    p
    a
    +2
    • 5
    • 6
  • s

    Shane Blackburn

    11/01/2019, 5:06 PM
    Does anyone have a good resource for learning collections in Kotlin? That is the one place I seem to really be struggling
    w
    j
    h
    • 4
    • 6
  • t

    Toddobryan

    11/02/2019, 2:03 AM
    Can anybody think why this resolves to type
    Any?
    instead of
    Number?
    fun String.toNumber(): Number? = toIntOrNull() ?: toLongOrNull() ?: toBigIntegerOrNull()
    m
    h
    +2
    • 5
    • 11
  • j

    jimn

    11/02/2019, 1:50 PM
    @h0tk3y where is better-parse used in? i see it's on life support, would love to know more
    h
    • 2
    • 1
  • r

    RobinVdB

    11/02/2019, 5:07 PM
    Is there any way to do reflection at compile time? I want to dynamically create an interface. Use case is as follows: I have a base class (Let's call it foo) and I want to get all the subclasses of foo. Then I want to create an interface which creates a method (all with the same paramters and return type) for each and every subclass of foo
    n
    a
    t
    • 4
    • 14
  • h

    Hullaballoonatic

    11/02/2019, 7:37 PM
    Why is JB reluctant to add sum/union types? e.g.
    fun <N: Int | Byte> foo(n : N) = n.toDouble() / 4.5
    TypeScript has them, so I'd imagine JB would want to have it for Kotlin/JS.
    n
    m
    +6
    • 9
    • 36
  • h

    Hullaballoonatic

    11/02/2019, 8:34 PM
    i'd imagine it'd be better if
    fizz
    returned nullable, then
    foo.fizz()?.log()
    w
    t
    • 3
    • 18
  • j

    John

    11/03/2019, 5:26 PM
    Is there a kotlin function to scope an object on a condition? Something like
    withIf(myObject.propertyToFiler == true) { myObject -> ... }
    m
    s
    • 3
    • 5
  • c

    Cody Moore

    11/03/2019, 9:25 PM
    Hey Kotlin devs, I just released my first open source kotlin library for string case conversion and detection, which can be useful for things like generating code. It's stable as I have used it for other projects already. I'd love any feedback from the community! https://github.com/dotCipher/kase-format
    👍 3
    k
    • 2
    • 1
  • v

    Vishnu Haridas

    11/04/2019, 10:05 AM
    Which is better, a
    val
    with a backing property, or a public property with a private setter? Is there any difference? For example,
    class Foo {
    
        // (1) - public property with a private setter
        var isSyncing = false
            private set
        
        // (2) - val with a backing property
        private var isSyncing_ = false
        val isSyncing get() = isSyncing_
    }
    ➕ 1
    h
    s
    b
    • 4
    • 8
  • m

    Melvin Biamont

    11/04/2019, 2:00 PM
    Hello, I’ve a question regarding
    inline functions
    . How can I make an inline function stopping/returning the calling function?
    Basically, I would like this :
    //This method should return the calling function
    inline fun onUserNull() = run {
      Timber.e("User is null")
      return
    }
    
    fun fetchUserIdentity() {
      val currentUser = userDataSource.currentUser ?: onUserNull()
    
      presenter.displayUserIdentity(currentUser)
    }
    Would do the same as:
    fun fetchUserIdentity() {
      val currentUser = userDataSource.currentUser ?: run {
        Timber.e("User is null")
        return
      }
    
      presenter.displayUserIdentity(currentUser)
    }
    a
    l
    c
    • 4
    • 15
  • p

    pavi2410

    11/04/2019, 6:28 PM
    Is T::class a method reference? Can this operator
    ::
    be overloaded?
    r
    • 2
    • 2
Powered by Linen
Title
p

pavi2410

11/04/2019, 6:28 PM
Is T::class a method reference? Can this operator
::
be overloaded?
r

Ruckus

11/04/2019, 6:28 PM
No and no
p

pavi2410

11/04/2019, 6:32 PM
Thanks and Thanks
🤣 2
View count: 1