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

    bbaldino

    03/19/2019, 8:25 PM
    i need a 'resettable lazy' delegate, i've seen a few implementations online (https://stackoverflow.com/questions/35752575/kotlin-lazy-properties-and-values-reset-a-resettable-lazy-delegate, https://stackoverflow.com/questions/37294183/lazy-variable-with-reset, https://gist.github.com/bj0/f4871f90263bc7d2a71c13f6d61710b0) but they're all a bit old...is there a better way these days?
    s
    • 2
    • 27
  • r

    roberto

    03/20/2019, 2:36 AM
    hello, I've an issue with parameters visibility and constructors. I google the problem but I wasn't able to find any solution, so given the following code:
    class MyAwesomeView: FrameLayout {
    	constructor(context: Context?, attrs: AttributeSet? = null) : super(context, attrs)
    	constructor(context: Context?, attrs: AttributeSet?, parm1: Int) : super(context, attrs, parm1)
    	constructor(context: Context?, attrs: AttributeSet?, parm1: Int, parm2: Int) : super(context, attrs, parm1, parm2)
    	
    	init {
    		context.someMethod(attrs)
    	}
    }
    The init method cannot access attrs, I'm getting "Unresolved reference 'attrs'". Why is that? how can I make init access attrs. Shouldn't be enough by adding attrs to constructors as it is here?
    n
    d
    +2
    • 5
    • 9
  • p

    Paul Woitaschek

    03/20/2019, 11:55 AM
    On a data class, a property is never shown as unused because it's used in toString, equals & hashcode. So when I want to find unsued properties I would manually need to remove the `data`modifier. Is there any way around that?
    c
    • 2
    • 1
  • j

    juliocbcotta

    03/20/2019, 2:42 PM
    Does using
    internal
    in my gradle modules classes makes the project compilation time smaller or improves the IDE memory/processor usage? If so, Is there any docs/articles about this?
    a
    g
    • 3
    • 2
  • k

    klizter

    03/20/2019, 3:07 PM
    Is it possible to create Kotlin
    Map
    where key is
    String
    and case insensitive?
    a
    a
    +4
    • 7
    • 21
  • a

    amanda.hinchman-dominguez

    03/20/2019, 3:11 PM
    Oh, hold on. Lists do have that covariance in the interface itself. Nevermind!
    s
    • 2
    • 1
  • p

    Paul Woitaschek

    03/20/2019, 4:09 PM
    Does someone know which bigger companies use kotlin native for shared logic between iOS and android? I'm advocating for that within my company and would like to quote that we're not the only company doing this on the earth 😉
    👍 2
    m
    r
    +2
    • 5
    • 17
  • b

    basher

    03/20/2019, 9:36 PM
    Does the default implementation of a Kotlin object's hashCode work how it does in Java, where it returns some identity hashCode that reflects object ===-type equality?
    d
    • 2
    • 2
  • t

    turansky

    03/20/2019, 11:52 PM
    What is better pair methor name for
    truncate
    ? https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.math/truncate.html 1.
    fraction
    2.
    fractional
    2️⃣ 2
    1️⃣ 1
    :no_red: 1
    i
    i
    • 3
    • 8
  • s

    Sola

    03/21/2019, 9:17 AM
    I'm experiencing an unexpected compile error with new inference (
    -Xnew-inference
    ), is this a known issue? (It compiles with old inference implementation, btw)
    m
    • 2
    • 2
  • u

    Ubi

    03/21/2019, 9:51 AM
    Is it possible to have an inline block of code that returns an object. In the example below you have to “manually” call
    invoke()
    . Is there any other way to achieve this?
    -.kt
    d
    w
    • 3
    • 4
  • p

    Paul Woitaschek

    03/21/2019, 11:09 AM
    Why are functions like
    .sumBy()
    not defined on
    kotlin.collections.Iterator<T>
    too? I'm using android-ktx
    fun <T> androidx.collection.SparseArrayCompat<T>.valueIterator(): kotlin.collections.Iterator<T>
    and would like to sum the values. As a workaround I can call
    toSequence().sumBy { it }
    k
    • 2
    • 2
  • a

    amadeu01

    03/21/2019, 12:48 PM
    guys, how to you open like a
    kotlin repl
    but with some library included. Eg: I want to make a test with RxKotlin, but I just want to see the result of something, is that possible to make a import of the library to the repl ?
    g
    • 2
    • 7
  • i

    Ian White

    03/21/2019, 1:10 PM
    I’m writing an annotation processor using Kapt and KotlinPoet; am I correct in thinking that there is no way to detect nullability on parameterized type values? i.e. I cannot distinguish
    myMap: Map<String,Any>
    from
    myMap: Map<String,Any?>
    , because both of those turn into Java
    Map<String,Object>
    from the standpoint of the annotation processor. Is there any way to distinguish them? As a workaround I’m considering adding an additional annotation
    @HasNullValue
    but it’s a bit of a hack.
    d
    • 2
    • 2
  • s

    Slackbot

    03/21/2019, 4:05 PM
    This message was deleted.
    s
    e
    • 3
    • 2
  • k

    karelpeeters

    03/21/2019, 5:15 PM
    You can't. Chars are primitives and so they don't have an identity (unless there's boxing involved but even then it's still a bad idea to depend on identity anyway). In this case you could check the index instead:
    if (indice == composizione.lastIndex)
    s
    • 2
    • 1
  • d

    David Cuesta

    03/21/2019, 6:31 PM
    hey guys, is there a way of overloading the operator "->"?
    🇳🇴 3
    s
    k
    • 3
    • 5
  • d

    ddlucas

    03/21/2019, 7:05 PM
    @David Cuesta if only they used => instead of >= you could use the compareTo
    l
    • 2
    • 1
  • l

    LeoColman

    03/22/2019, 1:17 AM
    fun Any?.foo(other: Any?) {
        contract {
            other == null implies (this != null)
        }
    }
    d
    • 2
    • 3
  • g

    Guru

    03/22/2019, 8:43 AM
    according to http://kotlinlang.org coroutineScope{...} will not block the current thread while waiting for all children to complete.
    g
    • 2
    • 2
  • s

    spand

    03/22/2019, 8:54 AM
    It wont return until all children are complete but the thread is not blocked
    g
    • 2
    • 1
  • k

    klizter

    03/22/2019, 8:57 AM
    Hey! Is it possible to swap two elements in a mutableList? Can’t find any swap method.
    g
    d
    • 3
    • 3
  • a

    Antanas A.

    03/22/2019, 12:01 PM
    I think it's better to use "launch" instead of "coroutineScope" in your case
    g
    • 2
    • 1
  • g

    Guru

    03/22/2019, 12:26 PM
    @Antanas A. - I just shifted my lauch3 just above coroutineScope{...} and it works just fine. But, surprisingly any thing below coroutineScope{...} is never gonna execute...!! It is blocking..! May be its a bug. I have no idea.!
    g
    a
    t
    • 4
    • 38
  • h

    hdarritchon

    03/22/2019, 3:45 PM
    And do you know if it will be available one day or it’s a limitation of Kotlin ?
    s
    a
    • 3
    • 8
  • l

    liminal

    03/22/2019, 4:31 PM
    aggregate_function_question.kt
    s
    w
    a
    • 4
    • 10
  • t

    tipsy

    03/22/2019, 7:50 PM
    is there any way to freeze a java object? i have a framework which exposes a class like this
    class Person {
        public int age;
        public String name;
    }
    and i want to turn it into a
    data class(val age: Int, val name: String)
    . i know i could write something to convert it, but is there something built-in that can just freeze the object instead?
    a
    d
    g
    • 4
    • 6
  • s

    Slackbot

    03/22/2019, 8:53 PM
    This message was deleted.
    d
    h
    • 3
    • 2
  • k

    Kirill Zhukov

    03/22/2019, 10:58 PM
    Or rather, it is, but it has different naming,
    BigDecimal#toInt()
    which maps to
    intValue()
    . Curious how this is done.
    d
    j
    • 3
    • 4
  • h

    Hamza

    03/23/2019, 5:19 PM
    Is it possible to make kotlin able to compile for .NET
    🇳🇴 3
    s
    • 2
    • 4
Powered by Linen
Title
h

Hamza

03/23/2019, 5:19 PM
Is it possible to make kotlin able to compile for .NET
🇳🇴 3
s

Shawn

03/23/2019, 5:42 PM
short answer: no
long answer: compile to jvm bytecode and transpile to CLR using something like ikvm
do so entirely at your own risk because I doubt anyone else is doing this
h

Hamza

03/24/2019, 10:55 AM
Will it ever support it
View count: 7