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

    bostonmacosx

    09/14/2017, 1:10 PM
    I'm coming from iOS development and I'm having some issues with Fuel HTTP
    o
    • 2
    • 1
  • j

    Jvidal

    09/14/2017, 3:09 PM
    it’ is possible use content provider with the new library Room
    k
    j
    • 3
    • 3
  • k

    karelpeeters

    09/14/2017, 3:24 PM
    Damm I really can't find it. Might have been taken down?
    j
    • 2
    • 1
  • i

    ilya.gorbunov

    09/14/2017, 5:09 PM
    @karelpeeters Is it this one? https://github.com/DemonWav/kotlin-utils Nice syntax, but beware it costs extra two objects per
    using
    block.
    🤘 1
    k
    j
    • 3
    • 6
  • d

    dalexander

    09/14/2017, 8:02 PM
    Inlining methods at compile-time isn’t always faster. The way hotspot handles certain things is pretty complex.
    e
    • 2
    • 1
  • d

    diesieben07

    09/14/2017, 8:48 PM
    I am very surprised amazingscript is not a thing.
    o
    • 2
    • 1
  • t

    tianhao

    09/15/2017, 12:36 AM
    Any good tool recommended for Kotlin test coverage? Jacoco looks like not quite friendly for Kotlin.
    a
    • 2
    • 1
  • q

    qwert_ukg

    09/15/2017, 3:09 PM
    i want to add
    get
    operator to my type and do something like this
    array["a", true, null, 1]
    k
    • 2
    • 7
  • k

    karelpeeters

    09/15/2017, 3:31 PM
    Sure, but one might argue that
    Person("Dave", age = 30)
    is also resolvable at compile-time. Is there anything else that requires
    const
    ?
    r
    b
    • 3
    • 8
  • k

    karelpeeters

    09/15/2017, 7:17 PM
    That's indeed what it does on the JDK version, but the JS version doesn't work, looks like
    Unit
    is considered
    null
    there. The result if I run the code there is
    a
    error
    :youtrack: 3
    b
    • 2
    • 5
  • d

    Dalinar

    09/16/2017, 3:02 AM
    why and when were commas deprecated (in
    when
    )? is it ok to keep using them?
    h
    r
    • 3
    • 4
  • d

    Dalinar

    09/16/2017, 3:15 AM
    does anyone know what would cause a squiggly underline under a pacakage name (folder actually exists) in a class that is specified fully qualified in code? (for example if I were creating a new object from a fully qualified class, e.g.
    a.squiggly b.c.d.MyClass()
    )
    h
    k
    • 3
    • 12
  • e

    egoscio

    09/16/2017, 9:11 AM
    I'm getting the following warning, and I've tried googling without any luck:
    [kts] kotlin.script.experimental.dependencies.DependenciesResolver.NoDependencies must have a constructor without required parameters
    o
    • 2
    • 3
  • n

    nil2l

    09/16/2017, 8:38 PM
    Do you mean exception in constructor?
    d
    k
    • 3
    • 8
  • k

    karelpeeters

    09/16/2017, 8:50 PM
    To actually answer your question, if the parent constructor has at least one parameter you can use this trick to run whatever code you want:
    super(param.also { ... })
    d
    n
    • 3
    • 16
  • r

    redrield

    09/17/2017, 12:49 AM
    What would people recommend for NLP/NLU in Kotlin?
    o
    • 2
    • 1
  • h

    harmony

    09/17/2017, 5:46 AM
    any eta for kotlin 1.2?
    d
    • 2
    • 2
  • m

    mortda-m

    09/17/2017, 3:30 PM
    is it possible to write react in kotlin?
    k
    • 2
    • 1
  • f

    fstn

    09/17/2017, 5:04 PM
    Facebook Chatbot: vertx + java, vertx + scala or vertx + kotlin for a 10 years jee developer?
    e
    g
    • 3
    • 4
  • l

    lovis

    09/18/2017, 9:20 AM
    the issue here is the name
    list
    .
    x
    ,
    y
    , or
    foo
    would be equally informative….
    c
    • 2
    • 4
  • n

    neil.armstrong

    09/18/2017, 10:55 AM
    hmm, I’d probably autogenerate the field name as camelcase then
  • n

    nil2l

    09/18/2017, 12:00 PM
    This article is about problems of automatic case mapping. Other is ok.
    Let's stop with this nonsense. Either by explicitly declaring the mapping (choice 2) or by avoiding the mapping altogether (choice 3).
    l
    • 2
    • 1
  • m

    mike_shysh

    09/18/2017, 12:10 PM
    @nil2l he notifies that these annotations just a unnecessary thing, they make a data class less readable. When he need to modify data class, he should manage this field as well
    n
    • 2
    • 1
  • r

    reline

    09/18/2017, 1:34 PM
    hey guys, I'm having a problem here where when
    myString == null
    it matches both the
    String?
    and
    Int?
    types. Anyone know a way around this?
    fun hello(myString: String?, myBoolean: Boolean) {}
    
    fun hello(myInt: Int?, myBoolean: Boolean) {}
    
    fun hi(myString: String?) {
        if (myString == null) {
            hello(myString, false) //overload resolution ambiguity
        } else {
            hello(myString, true) // this works fine
        }
    }
    m
    • 2
    • 2
  • a

    anstaendig

    09/18/2017, 1:38 PM
    Don’t allow myString and myInt to be null in the first place 😎
    s
    r
    • 3
    • 5
  • k

    kevinmost

    09/18/2017, 10:00 PM
    you're totally allowed to use a lot of the keywords in Kotlin outside of their normal context
    t
    • 2
    • 2
  • o

    orangy

    09/18/2017, 10:10 PM
    This concept allows evolving language easier in the future. You can’t normally add another hard keyword without breaking some code. E.g. we added
    suspend
    in 1.1 without breaking any code that might be using
    val suspend = shouldSuspendUser()
    💯 12
    t
    k
    +3
    • 6
    • 13
  • a

    adams2

    09/18/2017, 10:52 PM
    when would you return null for Unit?
    o
    • 2
    • 1
  • d

    Dalinar

    09/19/2017, 6:20 AM
    is it ok to override a java default method (in the kotlin subclass interface of the java interface)? I ask because you can't call it via super so was wondering if there could be any unforseen consequences
    k
    • 2
    • 2
  • e

    edwardwongtl

    09/19/2017, 8:39 AM
    val A.extVal get() = B(this)
    Is there a way to not construct
    B
    every time I reference to
    A.extVal
    ? Given that I don't own class
    A
    .
    m
    i
    • 3
    • 8
Powered by Linen
Title
e

edwardwongtl

09/19/2017, 8:39 AM
val A.extVal get() = B(this)
Is there a way to not construct
B
every time I reference to
A.extVal
? Given that I don't own class
A
.
m

marstran

09/19/2017, 9:06 AM
I tried using the
lazy
-delegate, but it didn't work because you don't have access to
this
inside the function you pass to it. I guess you could create your own version of the
lazy
-delegate that passes the receiver object as a parameter to the function though.
You can read how to do this here: https://kotlinlang.org/docs/reference/delegated-properties.html
This kinda works, but it is not thread safe:
class LazyExtension<V, T>(val f: V.() -> T) {
    data class Result<T>(val t: T)
    var result: Result<T>? = null
    
    operator fun getValue(thisRef: V, property: kotlin.reflect.KProperty<*>): T {
        return result?.t ?: Result(thisRef.f()).also { 
            result = it
        }.t
    }
}
👍 2
e

edwardwongtl

09/19/2017, 10:22 AM
Wow thanks man, I will take a look
m

marstran

09/19/2017, 10:49 AM
I fixed it up a little bit so it doesn't use that
tmp
variable.
i

ilya.gorbunov

09/19/2017, 10:52 AM
@marstran Note that this implementation of LazyExtension would return the same value for any receiver after it had been initialized. Probably not what the author wanted.
m

marstran

09/19/2017, 10:54 AM
Ah, that's true. You would also need to keep track of all the receivers.
I guess that could turn out to be quite a memory leak if it is used a lot.
View count: 1