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

    jkbbwr

    01/06/2018, 2:07 AM
    How can I port
    byte b1 = (byte) 0xAD;
    byte b2 = (byte) 0xCA;
    short s = (short) (b1<<8 | b2);
    m
    l
    • 3
    • 2
  • k

    karelpeeters

    01/06/2018, 9:59 AM
    @Dave Leeds I can't really find anything, none of these are an error:
    class Test<out T>(val a: T) {
        val b: T? = null
        fun derp() {
            val b: T
        }
    }
    d
    • 2
    • 3
  • a

    alexcouch

    01/07/2018, 6:16 AM
    So I was looking around seeing if kotlin had a way of declaring multiple variables in a single line. I saw that it's not desired for properties which I can understand with how its syntax is. But what I'm thinking about is local vars/vals and even top-level var/val declarations. Mostly local vars/vals. I also get that the syntax doesn't really allow it but I was thinking that the destructuring declaration syntax could possibly be used in some way like
    var (str1, str2): String
    as a way of declaring a local/top-level var/val to be of whatever type you want it to be, and only as long as you want them both to be a var or a val as I've shown (otherwise it'd be counter intuitive). Is there a hacky way of doing so, or is it just not at all desired and for what reason?
    a
    c
    • 3
    • 7
  • c

    czyzby

    01/07/2018, 10:45 AM
    Were Kotlin Census 2017 results published?
    s
    t
    • 3
    • 4
  • d

    dh44t

    01/08/2018, 11:54 AM
    you could wrapped into a method that doesn't take a
    suspend
    lambda
    q
    g
    • 3
    • 6
  • y

    yaakov

    01/08/2018, 5:11 PM
    On a side note: if I want to do an index for loop do I need to use .forEachIndexed or could I just use an overload?
    a
    • 2
    • 4
  • h

    helpermethod

    01/09/2018, 8:45 AM
    cases.xPath = "//"
    doesn't seem to work
    d
    • 2
    • 1
  • j

    jkbbwr

    01/09/2018, 12:54 PM
    How does one set up spek or is there an alternative
    k
    o
    • 3
    • 2
  • t

    tess_snow

    01/09/2018, 1:17 PM
    looking for something like xmlslurper (groovy) for kotlin. Kotlin XML Binding (http://jonnyzzz.com/blog/2016/01/06/kotlin-xml/) seems useable. Opinions? Need to figure out how to parse an XML string into an object too using this lib..
    k
    k
    • 3
    • 9
  • l

    lovis

    01/09/2018, 2:46 PM
    if you still want to keep the interface, just put a default inside the interface. like this
    interface BootstrapListener {
        fun onBootstrapComplete()
        
        object DoNothing : BootstrapListener {
            override fun onBootstrapComplete() {}
        }
    }
    
    class PlayoutSocketClient(..., private val bootstrapListener: BootstrapListener = BootstrapListener.DoNothing)
    k
    • 2
    • 1
  • m

    menegatti

    01/09/2018, 4:09 PM
    or if the parameters are not constructor ones
    😮 1
    a
    • 2
    • 4
  • a

    araqnid

    01/09/2018, 4:18 PM
    maybe enclose the sensitive data in a wrapper that redacts its value, and then you can include those in data classes freely (kind of like how some apps put passwords in character arrays just to hide the default toString output)
    m
    • 2
    • 1
  • d

    dSebastien

    01/09/2018, 8:10 PM
    I'm really curious to see what we can already do today with Kotlin's JS target and how it works with TypeScript typings and front-end libraries/tooling. Has anyone some links to articles about this or proof-of-concepts done with React, Angular or Vue.js?
    y
    g
    t
    • 4
    • 3
  • y

    yaakov

    01/09/2018, 8:48 PM
    I hear Kotlin native has support for WASM now (but it's not intended to be production heavy). Not really sure why WASM compilation is under Kotlin native and not Kotlin/JS though. Is WASM handled through a native compiler?
    g
    • 2
    • 1
  • s

    Shawn

    01/09/2018, 8:56 PM
    I don’t know much about computers, but I’d chalk it up to the fact that the Kotlin/JS compilation process emits javascript rather than an assembly-like IR
    y
    s
    • 3
    • 2
  • c

    cedric

    01/09/2018, 10:21 PM
    The main limitation with WASM right now is lack of access to the DOM, which makes it kind of pointless. But it’s being worked on.
    y
    g
    • 3
    • 2
  • c

    Czar

    01/10/2018, 1:51 PM
    If you only need a list of values, I'd use just
    filter
    to avoid creating a map
    m
    • 2
    • 3
  • m

    mike_shysh

    01/10/2018, 1:54 PM
    testDataConst.filterKeys { it.contains("NodeForDelete") }
                            .values.map { NodeID(it) } << need to create an object=)
                            .toList()
    c
    • 2
    • 2
  • y

    yaakov

    01/10/2018, 4:52 PM
    Does KotlinConf have an entry fee or is it free?
    h
    k
    l
    • 4
    • 6
  • c

    cravalec

    01/10/2018, 5:01 PM
    Hy @hhariri here at Kotlin Paris meetup (France) would like to organize a Kotlin conference in Paris in 2018. Can whe discuss about it and see if we find other volunteer in the comunity in Europe to work with us on the project.
    🇫🇷 1
    ➕ 1
    h
    • 2
    • 1
  • m

    Michael H. Cox (Mike) (he/him)

    01/11/2018, 12:51 AM
    https://plus.google.com/+DaveLeeds/posts/AwnHZieG29M?_utm_source=1-2-2
    🐢 1
    😂 1
    g
    • 2
    • 1
  • q

    qwert_ukg

    01/11/2018, 2:59 AM
    Heard JB have some problems with interface delegation. Should i care about my decorators, or everything will be fine?
    l
    • 2
    • 1
  • c

    cedric

    01/11/2018, 5:02 AM
    Save yourself headaches, put your tests in
    src/test/kotlin
    👍 1
    a
    • 2
    • 1
  • a

    alex2069

    01/11/2018, 6:49 AM
    @albertgao Not sure if it's related, but I had to turn on TestNG support for the tests (this was for an Android project though)
    // Configure TestNG
    project.afterEvaluate {
        def tests = project.getTasksByName("testDebugUnitTest", false) + project.getTasksByName("testReleaseUnitTest", false)
        tests.forEach {
            it.doFirst {
                useTestNG()
                testLogging.showStandardStreams = true
            }
        }
    }
    a
    • 2
    • 1
  • l

    louiscad

    01/11/2018, 11:07 AM
    Does anyone think having a
    sealed class
    inside another one is a bad idea? My use case is to represent the states of
    CameraCaptureSession
    from Android Camera2 API (see these state callbacks: https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.StateCallback.html) Here's my updated
    sealed class
    that is inside a custom
    CamCaptureSession
    class:
    sealed class State {
        sealed class Configured() : State() {
            companion object : Configured()
            sealed class InputQueueEmpty : Configured() {
                companion object : InputQueueEmpty()
                object Ready : InputQueueEmpty()
            }
    
            object Active : Configured()
        }
    
        sealed class Closed : State() {
            companion object : Closed()
            object ConfigureFailed : Closed()
        }
    }
    c
    r
    +2
    • 5
    • 11
  • t

    tschuchort

    01/11/2018, 1:37 PM
    does anyone here have experience with kotlinpoet and annotation processing? I want to add a method to an existing class
    l
    g
    • 3
    • 4
  • i

    Iain

    01/11/2018, 3:07 PM
    I have a view with a map fragment and a recycler view fragment. How can I ‘talk to’ the map from the recycler view adapter?
    :stackoverflow: 4
    d
    • 2
    • 3
  • r

    Roberto Fernandez

    01/11/2018, 5:33 PM
    guys, i have a question about kotlin + fold + function..here it is:
    fun getView(cardGraphs: List<Graph>): View {
    
    		val graphsContainer = RelativeLayout(context)
    		graphsContainer.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
    
    		cardGraphs.fold(null) { view: View?, graph: Graph ->
    			return addView(graphsContainer, view, getView(graph))
    		}
    
    		return graphsContainer
    	}
    With this code, my function getView (the main function) is returning whatever is the first return of the addView() inside fold..If i set return@fold it needs return Nothing? but my method addView() returns View so it has a type parameter errors.. Can someone explain what is happening here in both cases? and why?
    c
    • 2
    • 6
  • p

    Paul Woitaschek

    01/12/2018, 10:05 AM
    What is the reason that kotlins round signature
    fun round(x : Float) : Float
    returns float but javas Math.
    int round(float a)
    returns int?
    l
    • 2
    • 1
  • n

    Natsuki(开元米粉实力代购)

    01/12/2018, 11:11 AM
    @gildor the properties are defined in the top level, not in a class or object , so reflection for all properties in current file seems infeasible
    g
    • 2
    • 1
Powered by Linen
Title
n

Natsuki(开元米粉实力代购)

01/12/2018, 11:11 AM
@gildor the properties are defined in the top level, not in a class or object , so reflection for all properties in current file seems infeasible
g

gildor

01/12/2018, 11:37 AM
Do you use Kotlin Reflections or Java Reflections?
View count: 2