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

    jhonsef

    01/12/2018, 4:07 PM
    Good Afternoon, in Brazil
    👋 2
    🇧🇷 6
    m
    • 2
    • 1
  • i

    ilya.gorbunov

    01/13/2018, 4:29 AM
    @melanchroes You're adding the same
    path
    list every time to the
    results
    list. Then you're mutating it, eventually clearing it.
    m
    e
    • 3
    • 5
  • j

    Jordy Langen

    01/13/2018, 10:34 AM
    Hello all 👋 I don't want to spark a big discussion, and hopefully this is the right channel but I was wondering what the state of expression trees in Kotlin is. I see some messages stating that it's planned but I don't seen anything other than that. Anyone here has any idea?
    p
    a
    g
    • 4
    • 8
  • d

    dimcha

    01/13/2018, 4:21 PM
    my code
    // Java class
    public class BaseOne {
        public static void m1() {
            System.out.println("BaseOne");
        }
    }
    
    // redefined method in child _java_ class
    public class BaseThree extends BaseOne {
        public static void m1() {
            System.out.println("BaseThree");
        }
    }
    
    // Kotlin 
    class BaseTwo : BaseOne() {
            companion object { 
                    fun m1() { // Error raises here :(
                            println("BaseTwo")
                    }
            }
    }
    c
    s
    +4
    • 7
    • 14
  • a

    andyfleming

    01/14/2018, 8:46 AM
    Is there an estimated timeline for coroutines to graduate from experimental?
    l
    • 2
    • 3
  • a

    arekolek

    01/14/2018, 12:07 PM
    Using a closure:
    fun <T> LiveData<T>.distinct(): LiveData<T> {
        var lastValue: Any? = Any()
    
        return MediatorLiveData<T>().apply {
            addSource(this@distinct) {
                if (it != lastValue) {
                    lastValue = it
                    postValue(it)
                }
            }
        }
    }
    Or using a property of the object:
    fun <T> LiveData<T>.distinct(): LiveData<T> {
        return MediatorLiveData<T>().apply {
            addSource(this@distinct, object : Observer<T> {
    
                private var lastValue: Any? = Any()
    
                override fun onChanged(value: T?) {
                    if (value != lastValue) {
                        lastValue = value
                        postValue(value)
                    }
                }
    
            })
        }
    }
    Any arguments to prefer one over the other?
    1️⃣ 1
    c
    k
    • 3
    • 2
  • t

    tschuchort

    01/14/2018, 2:47 PM
    what's the best way to poll a queue in a loop? I suppose a normal for-loop wouldn't remove the elements from the queue
    a
    • 2
    • 5
  • l

    louiscad

    01/14/2018, 11:10 PM
    Are there coroutines or similar in Swift?
    y
    • 2
    • 2
  • p

    poohbar

    01/15/2018, 3:06 AM
    Yup, did anyone contradict that?
    a
    s
    • 3
    • 7
  • e

    edwardwongtl

    01/15/2018, 3:33 AM
    I remember they said there will be a way to check if a
    lateinit var
    is initialised or not, is that out already?
    g
    d
    • 3
    • 3
  • d

    dominik.sittel

    01/15/2018, 6:59 AM
    Auto generating code documentation with /** + enter for kdoc does not work in IntelliJ. Anyone an idea 💡 ?
    l
    c
    a
    • 4
    • 5
  • r

    rootandy

    01/15/2018, 10:59 AM
    is there a native channel, too?
    h
    c
    • 3
    • 4
  • g

    g4sarma

    01/15/2018, 1:12 PM
    Hi guys, is there a separate thread for Servlet / Jetty ?
    c
    d
    • 3
    • 4
  • j

    Jimmy Alvarez

    01/15/2018, 2:26 PM
    Hello guy, I have aquestion. What does "the fisrt class suppor for kotlin on Android" means?
    m
    g
    • 3
    • 3
  • m

    menegatti

    01/15/2018, 4:08 PM
    I think there has been some discussion already about assuming all platform type are nullable or something
    g
    • 2
    • 1
  • r

    ralf

    01/15/2018, 5:06 PM
    Is this a bug in the compiler? If I uncomment the two lines I get a compile error
    e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: org.jetbrains.kotlin.codegen.AccessorForPropertyDescriptor cannot be cast to org.jetbrains.kotlin.codegen.AccessorForPropertyBackingField
    Cause: org.jetbrains.kotlin.codegen.AccessorForPropertyDescriptor cannot be cast to org.jetbrains.kotlin.codegen.AccessorForPropertyBackingField
    File being compiled and position: (48,33) in /Users/rwondratschek/dev/projects/evernote/evernote/libs/style/fonts/src/main/kotlin/com/evernote/android/font/EvernoteFont.kt
    PsiElement: isInitialized
    The root cause was thrown at: ExpressionCodegen.java:1974
    private lateinit var typeface: Typeface
    
        fun getTypeface(context: Context): Typeface {
            if (!::typeface.isInitialized) {
                synchronized(this) {
    //                if (!::typeface.isInitialized) {
                        typeface = try {
                            if (fontRes >= 0) {
                                ResourcesCompat.getFont(context, fontRes) ?: Typeface.DEFAULT
                            } else {
                                Typeface.create(context.getString(stringFontRes), style)
                            }
                        } catch (t: Throwable) {
                            Log.e("Font", "Couldn't load font $this", t)
                            Typeface.DEFAULT
                        }
    //                }
                }
            }
    
            return typeface
        }
    :youtrack: 2
    • 1
    • 1
  • l

    leus

    01/15/2018, 6:26 PM
    I keep getting "Outdated Kotlin Runtime" in Intellij IDEA. How can I update the Runtime? (the "Update Runtime" link given by the IDE just tells me that updating the runtime is not yet supported)
    g
    r
    • 3
    • 11
  • c

    cedric

    01/16/2018, 4:12 AM
    @dave08 http://beust.com/weblog/2015/10/30/exploring-the-kotlin-standard-library/
    d
    • 2
    • 1
  • b

    bj0

    01/16/2018, 4:25 AM
    I've used
    with
    to scope extension functions/properties defined in an
    object
    , but thats about all
    d
    c
    • 3
    • 14
  • r

    robstoll

    01/16/2018, 10:12 AM
    I struggle to attach kotlin sources in a Java/Kotlin mixed project (it works all fine in a pure Kotlin project). I clicked on download sources and javadoc in the maven window and I see them under Project Structure but it still isn't displayed properly. Any idea?
    c
    • 2
    • 2
  • j

    jstuyts-squins

    01/16/2018, 10:16 AM
    @elect Sorry, but I was incorrect. This works for me. The type of
    cb
    is indeed
    Any
    , but I can still access
    framebufferSize
    . This is in a JVM module (
    apply plugin: 'kotlin'
    ) of a multi-platform project using Kotlin 1.2.10:
    val cb = object {
        val framebufferSize = 1
    }
    println(cb.framebufferSize)
    e
    a
    • 3
    • 4
  • d

    Dier

    01/16/2018, 11:18 AM
    Hi, I'm new in Kotlin, I have to make a project with Kotlin and Spring framework 5. I would like if it was possible, that someone could give me any idea where I can to show the kotlin's power. Thank you very much
    c
    r
    • 3
    • 6
  • z

    ziggy42

    01/16/2018, 2:25 PM
    basically to get a bytearray from an input stream
    r
    • 2
    • 12
  • j

    Jimmy Alvarez

    01/16/2018, 3:40 PM
    SO the question is, Is it good to say that create constructors with default values is expensive because it must spent resources on defining the other instances and also carry on woth all definitions of the constructors
    v
    a
    c
    • 4
    • 6
  • m

    mikaelhg

    01/16/2018, 4:45 PM
    Is there a tracking page for Java 9 compatibility in kotlin, kotlin-compiler, and the Maven plugins? Wondering if I should be working around the various warnings, such as Illegal reflective access by com.intellij.util.text.StringFactory (file:kotlin-compiler-1.2.10.jar) to constructor java.lang.String(char[],boolean)
    a
    • 2
    • 7
  • c

    cedric

    01/16/2018, 8:53 PM
    apply
    returns the receiver while
    with
    returns the last expression of the block. Different uses.
    d
    • 2
    • 1
  • g

    gildor

    01/17/2018, 1:42 AM
    Kotlin style guide recommends to use
    ==
    instead of elvis operator for nullable booleans:
    it?.equals(obj) ?: false || it == obj
    ->
    it?.equals(obj) == true || it == obj
    s
    • 2
    • 1
  • s

    StavFX

    01/17/2018, 1:57 AM
    You could just simplify this all to
    it == obj
    - the only caveat is that if
    it
    and
    obj
    are both
    null
    - you'll get
    true
    . If that's not desired, then this would yield the same result as the original code
    it != null && it == obj
    s
    s
    • 3
    • 6
  • a

    Ayden

    01/17/2018, 2:42 AM
    I don't understand why the output is
    0, 1, 4, 9, 16
    .
    a
    • 2
    • 1
  • a

    Ayden

    01/17/2018, 2:53 AM
    val x: IntArray = intArrayOf(1, 2, 3)
    val x = Array(3, {i -> i + 1})
    g
    • 2
    • 3
Powered by Linen
Title
a

Ayden

01/17/2018, 2:53 AM
val x: IntArray = intArrayOf(1, 2, 3)
val x = Array(3, {i -> i + 1})
g

gildor

01/17/2018, 3:03 AM
This syntax is wrong. You should use this one instead:
val x = Array(3, {i -> i + 1})
or even
val x = Array(3, { it + 1 })
Because
it
is default name of argument for lambda with a single argumunt
a

Ayden

01/17/2018, 4:31 AM
Noted. Thank you @gildor Just got back from meeting.
View count: 2