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

    tomtau

    05/23/2018, 9:52 AM
    Hi everyone, I wrote a simple annotation processor for generating equals methods that ignore specified field names. In case anyone finds this useful, it's here: https://github.com/tomtau/kotlin-equals-ignoring-fields
    d
    • 2
    • 10
  • g

    GarouDan

    05/23/2018, 1:04 PM
    Hi guys. I’m using the library Fuel for Kotlin: https://github.com/kittinunf/Fuel It’s very nice. But I was wondering, instead of doing some complex code like we usually did in JavaScript before, Kotlin (or can we find a way) to use some kind of `await`operator? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await For example:
    val (request, response, result) = await "<http://httpbin.org/get>".httpGet().responseString()
    instead of
    val (request, response, result) = "<http://httpbin.org/get>".httpGet().responseString() // without await and thread blocking
    a
    • 2
    • 3
  • g

    GarouDan

    05/23/2018, 1:29 PM
    wow, very nice, It’s what I’m looking for. I need to know how to enable this or check if it is enabled
    g
    • 2
    • 2
  • f

    frellan

    05/23/2018, 6:15 PM
    Hi, i have a question I can’t find the answer to I want to pass a function as a parameter, but I want to aswell send some parameters with that function, except one, that should iterate
    b
    • 2
    • 1
  • f

    frellan

    05/23/2018, 6:18 PM
    A named function but also with parameters
    s
    g
    • 3
    • 5
  • t

    Trent Telfer

    05/23/2018, 7:47 PM
    Hey guys, I’m trying to compile a project and am running into an issue where gradle (using kts) is complaining about my target JVM. Does anyone know how I would tell gradle (using kts) to target 1.8 instead of 1.6?
    n
    • 2
    • 1
  • w

    warriorprincess

    05/24/2018, 5:12 AM
    fun mergeTwoLists(l1: ListNode?, l2: ListNode?): ListNode? { var k1: ListNode? = l1; var k2: ListNode? = l2; var head: ListNode? // interleave head = k1; k1 = k1?.next while (k1?.next != null && k2?.next != null) { head?.next = k2; head = head?.next head?.next = k1; head = head?.next k1 = k1.next; k2 = k2.next // why no '?' necessary? because checkced above already? } // rest of elems from longer one var rest: ListNode? = if (k1?.next == null) k2 else k1 while (rest?.next != null) { head?.next = rest; head = head?.next rest = rest.next } return head } }
    g
    • 2
    • 42
  • d

    diesieben07

    05/24/2018, 9:34 AM
    val myList = listOf(1)
    val myNewList = myList + 2 // [1, 2]
    👍🏼 1
    w
    • 2
    • 1
  • d

    diesieben07

    05/24/2018, 11:34 AM
    Kotlin always passes by value. But if you "store an object in a variable" you are only storing a reference, that reference will then be passed by value.
    👍 1
    a
    g
    • 3
    • 5
  • z

    zmarkan

    05/24/2018, 2:16 PM
    hey everyone, I’m currently prepping the State of Kotlin report (maybe you’ve seen the survey floating in the first few months of the year) Currently working on a piece of visualisation and looking to get some feedback on it. I’m mostly interested in whether this approach works for the data I’m trying to visualise. Don’t worry about the design specifics(colours and shapes) - it’s just a concept at the moment. Any feedback would be much appreciated. Cheers! https://imgur.com/Ci7kDJb
    e
    t
    k
    • 4
    • 18
  • a

    Alowaniak

    05/24/2018, 2:32 PM
    is it possible to set a function as being a function of some other variable? e.g.
    class A { val x = X(); fun foo(some: Bar) = x::anotherFooAlsoAcceptingOneBar; }
    g
    • 2
    • 2
  • k

    karelpeeters

    05/24/2018, 6:57 PM
    And you can edit messages :)
    w
    • 2
    • 2
  • k

    karelpeeters

    05/24/2018, 7:01 PM
    Isn't the actual issue that the length should be
    j - i + 1
    ?
    w
    • 2
    • 48
  • n

    Nicolas Chaduc

    05/25/2018, 7:51 AM
    Hey, how can I write same in kotlin of that swift code :
    if let valueCatchNotNull = valueCanBeNull {
    } else {
    }
    we can catch value not null with
    ?.let
    but can’t use else
    o
    m
    g
    • 4
    • 5
  • k

    karelpeeters

    05/25/2018, 7:54 AM
    val copy = value
    if (copy != null) {} else {}
    n
    • 2
    • 4
  • n

    Nicolas Chaduc

    05/25/2018, 8:18 AM
    what do you think about two extensions :
    fun ifLet(value: Any?, code: ((Any) -> Unit)): Boolean {
        value?.let {
            code.invoke(it)
            return true
        }
        return false
    }
    
    fun Boolean.elseLet(code: () -> Unit) {
        if (!this) {
            code.invoke()
        }
    }
    for use :
    ifLet(myMutableValue, {
                System.out.println("Call of ifLet Code myInt value = $it")
            }).elseLet {
                System.out.println("Call of elseLet Code")
            }
    ?
    d
    • 2
    • 1
  • b

    brabo-hi

    05/25/2018, 10:18 AM
    is there a kotlin jvm network api ? or we have to use the Java one ?
    h
    j
    +3
    • 6
    • 11
  • a

    adjorno

    05/25/2018, 11:43 AM
    how to set coroutine context to Deferred?
    a
    • 2
    • 1
  • b

    brabo-hi

    05/25/2018, 11:58 AM
    i'm wondering is there is any tool to convert html to kotlin DSL? if not, can we start an open source project for that ?
    k
    o
    • 3
    • 7
  • j

    jackjill

    05/25/2018, 1:31 PM
    http://shitcode.net any contributions?
    h
    • 2
    • 1
  • o

    orangy

    05/25/2018, 1:41 PM
    :thread-please:
    🙇‍♂️ 1
    k
    j
    +2
    • 5
    • 15
  • p

    Paul Woitaschek

    05/25/2018, 1:41 PM
    I was hoping to be able to use @Parcelize on the sealed class but that doesn't seem possible
    d
    • 2
    • 1
  • p

    Paul Woitaschek

    05/25/2018, 1:51 PM
    Okay so I keep my serialization centralized
    k
    • 2
    • 2
  • p

    Paul Woitaschek

    05/25/2018, 1:54 PM
    Is there a solution for that or do I need to add sth like
    readEnumNullable
    a
    • 2
    • 1
  • r

    robstoll

    05/25/2018, 2:15 PM
    What would you do in this case
    val dowNotNull: DayOfWeek = parcel.readEnum<DayOfWeek>()
    if readInt() returns 0? I think you need two implementations anyway
    p
    g
    • 3
    • 6
  • d

    diesieben07

    05/25/2018, 3:16 PM
    Doing
    thing as Int?
    shows "useless cast"
    o
    • 2
    • 2
  • d

    diesieben07

    05/25/2018, 3:17 PM
    Will do.
    o
    j
    • 3
    • 8
  • s

    samir

    05/25/2018, 3:17 PM
    Should this work without including <SomeInterface> ?
    interface SomeInterface
    enum class SomeEnum: SomeInterface { ValueA, ValueB }
    
    fun someFun(array: Array<SomeInterface>) {}
    
    fun calls() {
    	val val1 = arrayOf<SomeInterface>(SomeEnum.ValueA, SomeEnum.ValueB) // Array<SomeInterface>
    	val val2 = arrayOf(SomeEnum.ValueA, SomeEnum.ValueB) // Array<SomeEnum>
    	val val3 = SomeEnum.values() // Array<SomeEnum>
    	val val4 = SomeEnum.values() as Array<SomeInterface> // Array<SomeInterface>
    	
    	someFun(arrayOf(SomeEnum.ValueA, SomeEnum.ValueB)) // Works
    	someFun(SomeEnum.values()) // Compiler error
    	
    	someFun(val1) // Works
    	someFun(val2) // Compiler error
    	someFun(val3) // Compiler error
    	someFun(val4) // Works
    }
    s
    • 2
    • 7
  • t

    tschuchort

    05/25/2018, 5:55 PM
    have you tried ::class? 🤔
    s
    • 2
    • 1
  • l

    lucasqueiroz

    05/26/2018, 3:32 AM
    Hey everyone! First of all, I want to introduce myself. I'm Lucas, a Software Developer from Brazil. Second, would #general be the place to ask questions about coding? Or is there a specific channel for that?
    👋 3
    s
    t
    • 3
    • 8
Powered by Linen
Title
l

lucasqueiroz

05/26/2018, 3:32 AM
Hey everyone! First of all, I want to introduce myself. I'm Lucas, a Software Developer from Brazil. Second, would #general be the place to ask questions about coding? Or is there a specific channel for that?
👋 3
s

Shawn

05/26/2018, 3:34 AM
most folks are out of the office or are otherwise not looking a Slack by now, so you probably won’t get much of a response
#general is for general questions about Kotlin specific, and most folks would prefer that you stay on topic
check out the channel listing by clicking
Channels
in the left sidebar, as well as the Common Channels section of the Kotlin Slack Code of Conduct (which you agreed to when making an account)
https://kotlinlang.org/community/slackccugl.html
l

lucasqueiroz

05/26/2018, 3:36 AM
Oh my question is about Kotlin, not about other languages
s

Shawn

05/26/2018, 3:36 AM
but the general ones I’d recommend are #getting-started, #codereview, and #random
feel free to ask away then
t

tipsy

05/26/2018, 7:04 AM
this channel or #getting-started
View count: 2