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

    Artem

    06/06/2018, 9:16 AM
    Hi all, probably it was already answered, but I wasn't able to find any discussion about it. So my question relies on smart casts of class properties. As we know, smart cast of mutable property of nullable type isn't possible (
    Smart cast to Type is impossible because propertyName is a mutable property that could have been changed by this time
    . It relies on fact, that between checking for null and call to property value could have been changed by another thread. Proposed solution is to bake reference in a local variable and operate with it. It is great that developers of languages thought about situation of shared states between two threads, but it's really awkward to see this message in a program which operates in main thread only. Having to bake all properties seems really redundant in this scenario. So my question is: is there any plan to introduce some way to mark property as thread safe? At least some annotation which will turn off this check?
    ➕ 2
    i
    • 2
    • 1
  • m

    mdinino

    06/06/2018, 2:56 PM
    @rook Is lateinit not threadsafe?
  • h

    hallvard

    06/06/2018, 3:26 PM
    Hey, I thought
    lazy
    was doing it
    synchronized
    ? Isn't it supposed to be thread safe?
    h
    • 2
    • 3
  • w

    wei

    06/06/2018, 5:21 PM
    safe call question on nullable variable: Let’s say I have a variable of type
    List<String>?
    and I want to check that it contains at least one element. Is it possible to use just one condition check? I’ve tried:
    val t: List<String>? = null
    println(t?.size != 0)
    and this prints
    true
    , which is not what I want. I tried:
    !t?.size?.equals(0)
    but I can’t use this in an
    if
    because it’s
    Boolean?
    .
    a
    • 2
    • 3
  • a

    Artem

    06/06/2018, 5:23 PM
    Another question: this code snipped:
    fun doStuff(input:String) {
       val split = input.split("foo", 0)
    }
    will not compile, but this one:
    fun doStuff(input:String) {
       val split = java.lang.String(input).split("foo", 0)
    }
    will be OK. Is it supposed behaviour (in other words, is it a bug or is it a feature)?
    a
    i
    • 3
    • 3
  • r

    Ruckus

    06/06/2018, 9:31 PM
    For some reason, I can't figure out what is going on here:
    class Ref<K: Comparable<K>, T>(val key: K, val value: T) : Comparable<Ref<K, T>> {
        override fun compareTo(other: Ref<K, T>) = key.compareTo(other.key)
    }
    
    fun main(args: Array<String>) {
        val list = mutableListOf<Ref<Int, *>>()
        list.sorted()  // ERROR: Ref<Int, *> is not a subtype of Comparable<Ref<Int, *>>
    }
    Any ideas?
    i
    • 2
    • 3
  • r

    Ruckus

    06/06/2018, 9:33 PM
    (Also, I know
    sortedBy { it.key }
    works. I'm trying to understand why
    *
    doesn't)
    k
    • 2
    • 1
  • j

    jw

    06/06/2018, 9:50 PM
    that should be a bug. clearly a CAT is a decrement, not an increment
    😂 4
    😺 1
    j
    • 2
    • 1
  • j

    jmccance

    06/06/2018, 9:50 PM
    What JVM version?
    b
    • 2
    • 6
  • b

    bdawg.io

    06/06/2018, 10:07 PM
    Submitted the issue, feel free to add additional context if you have any https://youtrack.jetbrains.net/issue/KT-24800
    s
    • 2
    • 4
  • g

    ghedeon

    06/07/2018, 10:14 AM
    @karelpeeters the challenge is the following. The
    foo
    field is injected via DI, so it has to be lateinit. The thing is, this field is used to build another one —
    bar
    . That's why the
    bar
    is lazy.
    @Inject
        lateinit var foo
    
        val bar by lazy {  foo.foo()   }
    Now, I'm wondering if I can hide all this trickery behind some delegate or something, so I'll end up with a clean
    bar
    initialization. Ideal:
    val bar by initBar() // somehow foo is injected inside?
    Or at least:
    @Inject
        lateinit var foo
    
        val bar by initBar(foo)
    p
    a
    k
    • 4
    • 25
  • a

    Andrei

    06/07/2018, 10:51 AM
    Does Exception/Throwable have a special status of same kind? Would it be okay to carry an additional state and functionality within Exception class?
    k
    k
    • 3
    • 7
  • a

    abhijeetguptag

    06/07/2018, 1:48 PM
    Pitney Bowes (pitneybowes.com) is organising SMB Challenge Small and Medium Business Challenge is a product and application development hackathon for small and medium business (SMBs) focused applications and solutions. More Details can be found at https://www.hackerearth.com/sprints/pitney-bowes-smb-challenge-2018/
    🚓 3
    a
    • 2
    • 1
  • w

    wouterdoeland

    06/07/2018, 6:11 PM
    Hi, I have an issue using some obfuscated code (net.minecraft.server): I'm trying to call this functions
    DataWatcherRegistry.b.a(7)
    but there is a conflict because there are two functions named
    a
    . One returns
    DataWatcherObject<T>
    (the one I want) and another returns
    T
    . How can I select the correct one, because right now, I'm getting some conflicts.
    a
    k
    • 3
    • 16
  • j

    jw

    06/07/2018, 7:26 PM
    that isn't a Kotlin-specific question.
    Call
    is a representation of the pending request and its execution mechanism (which can either be synchronous or asynchronous).
    ResponseBody
    is the body type, which in this case is a general wrapper around any HTTP response that will allow you to interpret it as bytes or a string or a stream.
    h
    • 2
    • 6
  • d

    Dmitry

    06/08/2018, 4:56 AM
    Kotlin named as one of the top languages to learn by IDG TechWorld: https://www.techworld.com/picture-gallery/careers/up-coming-programming-languages-for-developers-get-grips-with-3621455/
    e
    • 2
    • 1
  • a

    arekolek

    06/08/2018, 6:44 AM
    any working code example maybe? 😉
    ➕ 1
    s
    g
    • 3
    • 21
  • g

    gildor

    06/08/2018, 6:44 AM
    Imo explicit type declaration is good idea sometimes. Would be interesting to see real example
    s
    • 2
    • 1
  • s

    SUPERCILEX

    06/08/2018, 7:08 AM
    Anyone know the answer to https://discuss.kotlinlang.org/t/how-do-i-type-square-bracket-proper-in-kdoc/6906?
    k
    • 2
    • 3
  • k

    kokeroulis

    06/08/2018, 2:25 PM
    inside the option 2, you could also emit the getter and the setter and create a facade property in the object it self
    m
    • 2
    • 4
  • d

    dekans

    06/08/2018, 3:05 PM
    https://code.videolan.org/videolan/vlc-android/blob/master/vlc-android/src/org/videolan/vlc/interfaces/IEventsHandler.java
    l
    • 2
    • 3
  • k

    kotlin_questions

    06/08/2018, 4:54 PM
    What would you recommend for cross platform UI development?
    n
    k
    • 3
    • 3
  • i

    ikt

    06/08/2018, 6:27 PM
    I'm really looking for: "here is a bunch of failing unit tests; go fox it"
    🦊 1
    r
    • 2
    • 1
  • p

    purereborn

    06/08/2018, 7:08 PM
    I have a Map of <String, Object>, where the key string can be converted into an integer index <Int, Object> then I want to sort by the Int index and order the object to get a List<Object>. Is there a functional way to write that? Can I do a map on a Map and get a Map as the result?
    r
    • 2
    • 1
  • a

    adam-mcneilly

    06/08/2018, 7:12 PM
    something something great minds
    👍 3
  • i

    ikt

    06/08/2018, 9:02 PM
    My current approach for deploying kotlin functions to lambda requires running "aws lambda create-function ..." I already have done "aws configure" Is there a way to, in kotlin, right click a function and choose "deply on lambda with name ..." ?//
    o
    • 2
    • 1
  • s

    skennedy

    06/08/2018, 9:44 PM
    i’m having some issues with a deprecated function’s
    ReplaceWith
    argument. alt-enter is simply deleting the line i’m on, rather than changing it to what’s specified in
    ReplaceWith
    l
    • 2
    • 4
  • t

    tipsy

    06/09/2018, 9:35 AM
    is there any reason to prefer null over empty collection as return value in kotlin?
    ➕ 1
    l
    d
    • 3
    • 4
  • r

    robstoll

    06/09/2018, 1:24 PM
    how do you represent '\0' in Kotlin? The compiler throws an error mentioning illegal escape for '\0'
    i
    • 2
    • 2
  • a

    ahmed ali

    06/10/2018, 11:02 AM
    is it possible that one day flutter apps will be written in kotlin ?
    g
    • 2
    • 2
Powered by Linen
Title
a

ahmed ali

06/10/2018, 11:02 AM
is it possible that one day flutter apps will be written in kotlin ?
g

gildor

06/10/2018, 12:23 PM
I don't think so
Only if flutter will have some C bindings, so you could use it from Kotlin Native
View count: 5