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

    Andreas Sinz

    10/13/2017, 12:50 PM
    @kartikpatodi what are you trying to do? your second code returns a new instance of
    A
    and not an Integer
    k
    • 2
    • 7
  • f

    fstn

    10/13/2017, 1:39 PM
    What is the best way to associate by to a list if key is present multiple times
    associateBy(keySelector = { it.getAttributeValue(“name”) }, valueTransform = { it.getAttributeValue(“value”) ?: “” })
    m
    k
    • 3
    • 6
  • r

    ramonsgds

    10/13/2017, 6:08 PM
    Hey guys, I added a vector (svg format) to my app through “New”->“Vector Asset” and it was added to the drawable folder in the res folder. I see the icon on the drawable folder as ic_thumbsup.xml, but when setting the srcCompact property of the imageButton however, it is not listed. What should I do?
    k
    • 2
    • 1
  • j

    jormendez

    10/14/2017, 9:14 PM
    Is rxkotlin an rxjava replacement for when working with kotlin? Or both need to be added?
    e
    • 2
    • 1
  • f

    fstn

    10/15/2017, 11:22 AM
    Is it a bad thinks to use a lot object instead of classes?
    f
    s
    • 3
    • 23
  • m

    Markus Bergkvist

    10/17/2017, 9:01 AM
    I'm working on a Android-project (mixed java/kotlin) where I will extract parts of the current code to a separate library so that I can re-use it for a CLI-applikation. How do I configure the projects in Android Studio and IntelliJ to share this code/library? Please point me to the correct direction if this is not the forum for this kind of question.
    k
    • 2
    • 2
  • o

    oday

    10/17/2017, 9:33 AM
    so they’re both
    this
    , do I just cast
    this
    to that View when I need to use the view, and use
    this
    as is when I want to refer to the context?
    m
    d
    • 3
    • 33
  • o

    oday

    10/17/2017, 12:07 PM
    so if I have a data class that Im going to create a table according to, I dont want to be instantiating it with ID
    v
    • 2
    • 2
  • o

    oday

    10/17/2017, 12:07 PM
    so that I can set ID on it when I retrieve all objects from DB and I would get the DB-given ID
    k
    • 2
    • 1
  • l

    lclc

    10/17/2017, 12:21 PM
    Hi guys, I'm new to Kotlin and the Java world. I've installed IntelliJ IDEA and am with a Kotlin video tutorial. Should I start with learning/using Maven or Gradle? What is the 'default' / better integrated with IntelliJ
    t
    k
    p
    • 4
    • 12
  • a

    Android75

    10/17/2017, 3:53 PM
    im sorry for my question... i think identical question of 100000 of users 🙂, the best kotlin book?
    r
    • 2
    • 2
  • f

    ferbeb

    10/17/2017, 4:23 PM
    I understand const does not work for fields
    k
    • 2
    • 3
  • f

    fstn

    10/17/2017, 4:40 PM
    thanks @dalexander I tried a mix of both :
    val validConditions = mutableListOf<ConditionalLink>()
            val conditionalNextLink = node.nextLinks.map { it as ConditionalLink }
            validConditions.addAll(
                    conditionalNextLink
                            .filter { it.condition.condition.isNotEmpty() && checker.check(it.condition, message.body()) }
            )
            if (validConditions.isEmpty()) {
                validConditions.addAll(
                        conditionalNextLink
                                .filter { it.condition == Condition.ELSE }
                )
    
            }
            val validConditionsAsResponse = validConditions
                    .onEach { eventBus.send(it.eventName, message) }
                    .map { it.condition }
            
            message.reply(JsonObject().put("validConditions", validConditionsAsResponse))`
    d
    • 2
    • 2
  • d

    darych

    10/17/2017, 7:31 PM
    Hi guys! I don't understand what's the main differences between timer function and Timer.schedule? I want to run periodical task. As I understand both approaches are similar.
    👀 1
    k
    • 2
    • 2
  • f

    fstn

    10/18/2017, 6:45 AM
    How to mock a kotlin extension? I tried the mockito way but it doesn’t work
    Mockito.`when`(flowNode.getInputParameter(“response”)).thenReturn(“re”)
    d
    • 2
    • 4
  • f

    fstn

    10/18/2017, 9:24 AM
    I don’t know what’s wrong with that:
    val regex = Regex("""\bfuck\b""")
            assertTrue(regex matches "ok fuck you")
    there is no match
    d
    • 2
    • 3
  • i

    itsJoseph

    10/20/2017, 8:52 AM
    Good day, can you give me some sources on the implementation of retrofit on soap web service? I have this project where i need to POST a soap request
    j
    • 2
    • 2
  • s

    Sean Corfield

    10/23/2017, 4:46 PM
    Thanks @dalexander and @karelpeeters -- I'll take a look at Kobalt and if that doesn't help, I may ask in #kontributors (that had been suggested by @cfleming who's another Clojure guy that uses Kotlin).
    • 1
    • 2
  • m

    miha-x64

    10/23/2017, 7:14 PM
    How to suppress 'unused type parameter' warning? Both
    UNUSED_VARIABLE
    and
    UNUSED_PARAMETER
    not worked.
    d
    p
    • 3
    • 3
  • f

    fstn

    10/24/2017, 8:26 PM
    Hi guys, I have 1 mutualized set of data that will be query by multiple thread, the idea is to query this set and return and remove it from the set For example the set can contains ResquestObjects (date,level,subject) I need to query to find the last request with subject = A and immediately remove it in java I would have used synchronized for that is there a better solution? I use Kotlin, RxJava and Vertx
    :stackoverflow: 1
    d
    • 2
    • 3
  • f

    fred.deschenes

    10/25/2017, 7:29 PM
    you should probably look at more Kotlin-friendly DI containers (not that Guice/Dagger don't work, but they can be a PITA to use with Kotlin), I know #kodein has something like that
    c
    • 2
    • 1
  • t

    trevjones

    10/25/2017, 8:19 PM
    the type signature of the method must be a leaf node on your class hierarchy or dagger will miss things.
    c
    • 2
    • 3
  • e

    elect

    10/26/2017, 3:01 PM
    this
    infix fun ArrayList<*>.resize(newSize: Int) {
        when {
            size > newSize -> for (i in newSize until size) pop()
            newSize > size -> when(get(0)){
                is Dbvt.StkNN -> for (i in size until newSize) add(Dbvt.StkNN())
                is DbvtNode -> for (i in size until newSize) add(DbvtNode())
            }
        }
    }
    complains at
    add
    Out-projected type 'kotlin.collections.ArrayList<*> /* = java.util.ArrayList<*> */' prohibits the use of 'public open fun add(element: E): Boolean defined in java.util.ArrayList```
    i
    • 2
    • 6
  • b

    bdawg.io

    10/26/2017, 11:21 PM
    On another topic, Which would you choose? Goal: reassign
    filters[property]
    if merging two nullable sets yields a non-empty set 1️⃣
    val additional: Set<T>? = filterStates[requested]
    if (additional is Set<*> && additional.isNotEmpty()) {
        val current: Set<T>? = filters[property]
        if (current is Set<*> && current.isNotEmpty()) {
            filters[property] = current.plus(additional)
        } else {
            filters[property] = additional
        }
    }
    2️⃣
    filters[property].plusMaybe(filterStates[requested.value])?.let {
        filters[property] = it
    }
    
    fun <T : Any> Set<T>?.plusMaybe(other: Set<T>?): Set<T>? = (this ?: emptySet()).plus(other ?: emptySet()).takeIf { it.isNotEmpty() }
    1️⃣ 2
    2️⃣ 1
    d
    • 2
    • 7
  • k

    karelpeeters

    10/26/2017, 11:24 PM
    What does
    if (current is Set<*> && ...)
    even do? Check whether it isn't null?
    b
    b
    • 3
    • 10
  • s

    Sean Corfield

    10/27/2017, 6:09 PM
    return x to y?
    d
    • 2
    • 3
  • k

    karelpeeters

    10/29/2017, 3:26 PM
    The
    map
    ,
    filter
    , ... operations on Sequence are lazy, while the same operations on Iterator Iterable are eagerly evaluated.
    i
    • 2
    • 2
  • p

    Prateek

    10/30/2017, 3:52 AM
    Can anyone help me out with it please
    k
    • 2
    • 1
  • h

    Hexa

    10/31/2017, 10:39 AM
    any good Kotlin tutorials for someone with 2 yrs Java experience?
    s
    u
    • 3
    • 2
  • s

    Sean Corfield

    11/02/2017, 4:09 AM
    I found KotlinTest and that seems nice (I used ScalaTest back when I was doing Scala... about seven years ago).
    j
    r
    d
    • 4
    • 4
Powered by Linen
Title
s

Sean Corfield

11/02/2017, 4:09 AM
I found KotlinTest and that seems nice (I used ScalaTest back when I was doing Scala... about seven years ago).
j

jk

11/02/2017, 8:53 AM
There’s also Spek which also has an intellij plugin http://spekframework.org/ and a slack channel at #spek
r

roberto.guerra

11/02/2017, 2:20 PM
I use JUnit, haven’t found the need to use anything else tbh.
s

Sean Corfield

11/02/2017, 3:24 PM
Thanks. I'll take a look at Spek too. I don't like plain xUnit assert-style tests and I'm more used to BDD "wording" in my tests.
d

dave08

11/03/2017, 6:12 AM
You can try expekt for matchers with Spek, since it doesn't have it's own...
View count: 3