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

    ghedeon

    01/18/2019, 11:03 AM
    https://youtrack.jetbrains.com/issue/KT-29227
    m
    16 replies · 2 participants
  • p

    pniederw

    01/18/2019, 12:23 PM
    Should Kotlin libraries use Maven scope
    provided
    for their dependency on kotlin-stdlib?
    k
    t
    +1
    16 replies · 4 participants
  • d

    Dmitry Kandalov

    01/18/2019, 2:20 PM
    Why
    .
    is not allowed in kotlin function names even when backticked? Is there :youtrack: for this? (IIRC scala and groovy can have dots.)
    k
    8 replies · 2 participants
  • d

    domfox

    01/18/2019, 2:58 PM
    The generated code performs an explicit null check before calling
    substring
    , so you'd get a different exception in that case:
    @NotNull
       public static final String getDesc(@NotNull Class $receiver) {
          Intrinsics.checkParameterIsNotNull($receiver, "$receiver");
          if (Intrinsics.areEqual($receiver, Void.TYPE)) {
             return "V";
          } else {
             String var10000 = createArrayType($receiver).getName();
             Intrinsics.checkExpressionValueIsNotNull(var10000, "createArrayType().name");
             String var1 = var10000;
             byte var2 = 1;
             if (var1 == null) {
                throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
             } else {
                var10000 = var1.substring(var2);
                Intrinsics.checkExpressionValueIsNotNull(var10000, "(this as java.lang.String).substring(startIndex)");
                return StringsKt.replace$default(var10000, '.', '/', false, 4, (Object)null);
             }
          }
       }
    u
    k
    5 replies · 3 participants
  • e

    Eric O'Connell

    01/18/2019, 6:58 PM
    if you tell me what that acronym means!
    s
    2 replies · 2 participants
  • s

    Slackbot

    01/18/2019, 11:00 PM
    This message was deleted.
    ❤️ 5
    k
    h
    13 replies · 3 participants
  • d

    Davide Giuseppe Farella

    01/19/2019, 7:52 AM
    That_s_the_intended_usage__just_to_be_clearer.kt
    d
    5 replies · 2 participants
  • d

    Dalinar

    01/19/2019, 1:41 PM
    so do more people use kotlin now for android than for java?
    ❓ 2
    🔄 2
    g
    n
    +1
    3 replies · 4 participants
  • g

    grandstaish

    01/19/2019, 2:01 PM
    Hey Kotlin community. Could anyone help me understand why
    x::class
    produces
    KClass<out T>
    instead of just
    KClass<T>
    in the following snippet?
    class Test<T : Any>(val x: T) {
      fun type(): KClass<T> = x::class // doesn't compile bc types don't match!
    }
    And a follow-up question, is there any way to make this compile without having to cast the result of
    x::class
    to
    KClass<T>
    ?
    d
    1 reply · 2 participants
  • t

    thana

    01/19/2019, 4:12 PM
    how would you make sure then
    type
    represents `x`'s type?
    k
    g
    2 replies · 3 participants
  • a

    altavir

    01/19/2019, 5:12 PM
    message has been deleted
    ❤️ 1
    k
    l
    11 replies · 3 participants
  • s

    Santhosh

    01/19/2019, 5:20 PM
    Hi,I deployed my library in github private repository.and i implemeted in my another android application with many versions release.Today i updated my library and pushed into repositpory released new version but unfortunately it unable to sync gradle getting error like "ERROR: Failed to resolve: com.github" .i used jitpack also and meaven also. but unable to resolve..Please help to resolve issue. Thanks.
    n
    5 replies · 2 participants
  • d

    Dalinar

    01/20/2019, 7:03 AM
    just want to confirm this kind of code is ok
    when (foo?.bar) {..}
    - I can't see why it wouldn't be but just want to make sure about the null
    y
    5 replies · 2 participants
  • g

    gcx11

    01/20/2019, 1:26 PM
    Hello, why is there no autocast in this case? Seems like a bug to me
    open class Animal
    
    class Dog: Animal() {
        fun bark() = println("Huf huf!")
    }
    class Cat: Animal()
    
    fun main() {
        val numbers = arrayOf(1, 2, 3)
        foo(numbers, Cat())
    }
    
    fun foo(numbers: Array<Int>, animal: Animal) {
        if (numbers.isEmpty()) {
            return
        } else if (animal !is Dog) {
            return
        }
    
        println(animal) // no autocast here
    }
    a
    a
    +1
    14 replies · 4 participants
  • o

    otakusenpai

    01/20/2019, 1:31 PM
    Hello, doesn't this line of code add a Pair to the mutable list?
    val list = mutableListOf<Pair<String,String>>()
    ....
    list.add(Pair(foo,bar))
    But in my case this doesn't add a new item to the list. All this is done inside a coroutinescope from a object of a class which has the above code.
    a
    1 reply · 2 participants
  • h

    Happy

    01/20/2019, 7:28 PM
    Hi Anyone ca help me with OKR ?
    👋 1
    c
    2 replies · 2 participants
  • h

    Hullaballoonatic

    01/20/2019, 9:04 PM
    does any language have a swap operator? like
    <->
    or something? would be cool if kotlin had one. NVM just gonna use
    also
    k
    9 replies · 2 participants
  • r

    Ryan Lynch

    01/20/2019, 9:06 PM
    I am recruiting for a number of Senior Software Engineer #jobs in #Melbourne. Java, Kotlin, Microservices, etc. Permanent roles paying $100-$140k base + super + ESOP. Sorry if this is the wrong channel for this!
    c
    i
    3 replies · 3 participants
  • h

    Hullaballoonatic

    01/21/2019, 5:41 AM
    what is significant that prevents kotlin from allowing
    ..
    operator to create descending ranges like
    9..5
    ? Shouldn't it be somewhat trivial to put into the code to create one or the other based on the higher value? is it simply ambiguity?
    g
    6 replies · 2 participants
  • h

    Hullaballoonatic

    01/21/2019, 7:07 AM
    Why is it extension functions are always shadowed by class functions? It would be really useful to be able to override them in narrow scopes
    c
    k
    4 replies · 3 participants
  • d

    Dmytro TOLSTYI

    01/21/2019, 7:50 AM
    Hi guys. I got a strange situation with
    suspend
    function which I can't solve: I got function
    suspend fun one()
    which executes some code and then calls a function that accepts a callback function as a param. But, this param function is not suspend. The issue is that I need to call another suspend fun from that callback param function. Here's an example:
    suspend fun one() {
        doSomething()
        funWithNonSuspendCallback("data") {
            two() // I need to call it from here but this is not suspend scope anymore
        }
    }
    
    suspend fun two() {
    }
    a
    n
    3 replies · 3 participants
  • l

    louiscad

    01/21/2019, 8:55 AM
    Do unsigned numbers (
    UByte
    ,
    UShort
    ,
    UInt
    &
    ULong
    ) have their boxed versions cached in a reasonable range? On Android, all signed numbers are cached from -128 to +127 (i.e. full
    Byte
    range, and part of
    Short
    ,
    Integer
    and
    Long
    )
    k
    d
    2 replies · 3 participants
  • n

    natpryce

    01/21/2019, 9:38 AM
    In/Out variance declared on the type, not at the use site, is a huge win.
    a
    t
    2 replies · 3 participants
  • s

    Slackbot

    01/21/2019, 10:02 AM
    This message was deleted.
    p
    k
    2 replies · 3 participants
  • s

    Slackbot

    01/21/2019, 11:31 AM
    This message was deleted.
    m
    1 reply · 2 participants
  • l

    LeoColman

    01/21/2019, 12:01 PM
    I want to use
    Contract
    in my lib, to infer non-nullability in a nullable value, and let users use it. However I don't want to force the user to use the compiler option. Is this possible? Or should I wait for contracts release?
    s
    s
    +1
    9 replies · 4 participants
  • s

    snackycracky

    01/21/2019, 2:57 PM
    Hey 🙂 can I
    map
    a
    SortedSet
    without transitioning the whole thing to a
    List
    ?
    d
    a
    15 replies · 3 participants
  • k

    kschlesselmann

    01/21/2019, 4:18 PM
    @Casey Brooks Any way to fix that?
    c
    c
    +1
    4 replies · 4 participants
  • j

    jw

    01/21/2019, 4:49 PM
    Use
    @JvmName
    r
    c
    2 replies · 3 participants
  • d

    Dalinar

    01/21/2019, 6:30 PM
    is there a way to reference a top level fun that has the same name as a local variable? usually I would do
    Class.funname()
    , however there is no class here
    1 reply · 1 participant
Powered by Linen
Title
d

Dalinar

01/21/2019, 6:30 PM
is there a way to reference a top level fun that has the same name as a local variable? usually I would do
Class.funname()
, however there is no class here
found the answer https://stackoverflow.com/questions/45059018/how-to-call-a-toplevel-function-from-a-method-or-an-extension-function-of-the-sa
View count: 1