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

    krenvpravo

    09/25/2017, 2:30 PM
    Does anyone have a good example of how to unit test asynchronous code with coroutines? I'm thinking of something like TestSubscriber in RX
    d
    • 2
    • 2
  • a

    ariff

    09/25/2017, 10:19 PM
    is there a tutorial, or steps I can follow. Searched google but couldn't find a good workaround
    o
    • 2
    • 2
  • s

    snowe

    09/25/2017, 10:21 PM
    so the reverse of that. can I turn a string into a property!?
    d
    • 2
    • 7
  • d

    dhkim

    09/26/2017, 3:13 AM
    Does anybody have run kapt successfully on Java9? Due to soon-to-be-deprecated javax.xml.bind module, I'm getting an error saying javax.xml.bind.DataTypeConverter is not found. Adding a dependency to the maven artifact of javax.xml.bind in buildscript classpath, doesn't solve the problem completely. At runtime, I keep getting the class is not found. Any clue?
    k
    • 2
    • 1
  • s

    Slackbot

    09/26/2017, 9:13 AM
    This message was deleted.
    r
    k
    • 3
    • 2
  • d

    dragas

    09/26/2017, 9:46 AM
    Regardless, I'd suggest just talking to the person who's in charge of the API to change how it responds since it's not recommended to have numeric values as property names, if possible.
    s
    • 2
    • 11
  • a

    alexcouch

    09/26/2017, 5:56 PM
    I'm in a debate with some friends and we are wondering if kotlin/native is going to have GC
    o
    • 2
    • 1
  • r

    raulraja

    09/26/2017, 6:08 PM
    Can't function references specify type parameters?
    d
    a
    • 3
    • 10
  • m

    mortda-m

    09/26/2017, 7:52 PM
    @Shawn yes this syntax
    a
    • 2
    • 1
  • r

    raulraja

    09/26/2017, 7:56 PM
    @mortda-m just because the author wanted to include
    ?
    in the function name and since that is a reserved keyword for nullable types it needs to wrap it in backticks
    👍 1
    m
    g
    n
    • 4
    • 4
  • a

    agomez

    09/26/2017, 8:02 PM
    <T: IndexedAccess>
    d
    • 2
    • 4
  • s

    sqia09

    09/27/2017, 9:10 AM
    hey, how can I trim last 4 or 5 characters from string using collection functions?
    d
    m
    g
    • 4
    • 4
  • d

    dave08

    09/27/2017, 12:32 PM
    Is there a way to destructure a data class's properties into an array?
    g
    • 2
    • 3
  • j

    joelpedraza

    09/27/2017, 1:59 PM
    final boolean b;
    final double d;
    {
        final Random rng = new Random();
        final double r = rng.nextDouble();
        if (r < 0.5d) {
            b = false;
            d = r / 2;
        } else {
            b = true;
            d = r * 3;
        }
        // rng and r fall out of scope
    }
    Is it possible to express this in kotlin? using a run {} "block" is a lambda, and captured value initialization is forbidden.
    m
    n
    • 3
    • 15
  • k

    kristofdho

    09/27/2017, 2:00 PM
    use tripple backticks
    j
    • 2
    • 3
  • j

    joelpedraza

    09/27/2017, 2:24 PM
    inline fun <reified T> store(texelCoord: Vec3i, layer: Int, face: Int, level: Int, texel: T) {
           val blockSize = getSize(T::class)
    }
    Thanks @marstran
    e
    m
    • 3
    • 7
  • k

    kotlin_questions

    09/27/2017, 2:42 PM
    public static void main(String[] args) { int x = 2; int y = 3; Algo(x, y); } public static void Algo(int x, int y) { int tempX = x; x = y; y = tempX; System.out.printf("x = %d \ny = %d", x, y); }
    :stackoverflow: 2
    i
    • 2
    • 1
  • k

    kotlin_questions

    09/27/2017, 2:45 PM
    Isnt it the same in kotlin?
    e
    • 2
    • 2
  • k

    kotlin_questions

    09/27/2017, 2:49 PM
    whatever it is for doesn't really matter does it?
    😂 1
    a
    • 2
    • 1
  • k

    kotlin_questions

    09/27/2017, 2:53 PM
    thanks.
    😂 1
  • r

    raulraja

    09/27/2017, 8:53 PM
    Trying to understand the reason for future reference why
    inline
    functions marked as
    tailrec
    can't be recursive in Kotlin. Is that because of fear of inlining too much?. Shouldn't
    tailrec
    take precedence and what gets inline is just a
    while
    loop? Thanks!
    d
    • 2
    • 1
  • p

    pakoito

    09/27/2017, 10:34 PM
    which channel is the right one to ask about the serialization lib, I have a couple of questions
    k
    r
    • 3
    • 4
  • p

    pakoito

    09/28/2017, 12:00 AM
    is there built-in support for polymorphic arrays, and sealed classes?
    s
    • 2
    • 35
  • d

    dragas

    09/28/2017, 10:28 AM
    How does kotlin deal with code coverage? Last I checked (about 6 months ago) IntelliJ seemed to return 0% regardless of executed tests.
    a
    n
    p
    • 4
    • 3
  • l

    lex

    09/28/2017, 10:49 AM
    @dragas do you try jacoco?
    d
    z
    • 3
    • 4
  • j

    joelpedraza

    09/28/2017, 3:36 PM
    Can this accidental override be resolved (can i tell the compiler it's not an accident)?
    • 1
    • 1
  • m

    m

    09/28/2017, 6:56 PM
    which web frameworks have first class kotlin support and good traction for production use?
    o
    b
    • 3
    • 2
  • n

    nerses

    09/28/2017, 8:59 PM
    i think i’ve found a bug in kotlin converter, Java Code
    Collection<Long> values = fetchList();
                Long[] valuesAsArray = new Long[values.size()];
                values.toArray(valuesAsArray);
    Kotlin conversion
    val values = fetchList()
                val valuesAsArray = arrayOfNulls<Long>(values.size)
                values.toTypedArray()
    and all elements in valuesAsArray will be null
    l
    m
    k
    • 4
    • 11
  • s

    snowe

    09/28/2017, 10:52 PM
    any way to give
    Pair
    a different name for
    first
    and
    second
    when json serializing?
    🇳🇴 2
    t
    a
    +2
    • 5
    • 20
  • g

    gildor

    09/29/2017, 8:44 AM
    class test {
    private var projID: String? = null
      fun main() {
      projID = intent.getStringExtra(getString("test")).also { projID -> 
           if (projID != null) {
              val proj = Proj(projID)
          } else {
              // todo
          }
       }
      }
    }
    c
    • 2
    • 2
Powered by Linen
Title
g

gildor

09/29/2017, 8:44 AM
class test {
private var projID: String? = null
  fun main() {
  projID = intent.getStringExtra(getString("test")).also { projID -> 
       if (projID != null) {
          val proj = Proj(projID)
      } else {
          // todo
      }
   }
  }
}
c

Czar

09/29/2017, 8:46 AM
fun main() {
    val proj = intent.getStringExtra(getString("test"))?.let { projId = it; Proj(it) } ?: //todo
}
g

gildor

09/29/2017, 8:46 AM
yes, it’ also depends what is
todo
View count: 2