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

    Shawn

    06/16/2018, 5:37 PM
    I don’t think that’s a legal comparison, doubt there’s a
    compareTo(Any?)
    defined
    👍 2
    h
    k
    • 3
    • 16
  • h

    Hullaballoonatic

    06/16/2018, 6:21 PM
    is there a loop type that you can just enter the number of times you want to do it, or do you just always have to do
    for(i in 0 until numTimes)
    even though you won't be using the i at all?
    i
    • 2
    • 2
  • g

    gabrielfv

    06/16/2018, 8:53 PM
    Also reminds me of this: https://aphyr.com/posts/342-typing-the-technical-interview
    ➕ 1
    😂 1
    k
    b
    h
    • 4
    • 7
  • k

    karelpeeters

    06/16/2018, 9:10 PM
    If you want you can add an annotation to the classes with the corresponding json name, make the hierarchy out of sealed classes and iterate over them with reflection.
    h
    • 2
    • 17
  • h

    Hullaballoonatic

    06/16/2018, 9:13 PM
    well, namely sealed classes and annotation, but given that you think they'll work here, that at least gives me a direction to look into them and an idea on how to use them
    k
    • 2
    • 1
  • m

    miha-x64

    06/17/2018, 9:01 AM
    Ok, if the array — created in this function — being passed into a single vararg function by means of spread operator — was not captured by crossinline/noinline anonymous function — not mutated after vararg function call then it should not be copied 🙂 Behaviour of
    varargFunction(a, b, c)
    will then be equal to
    varargFunction(*arrayOf(a, b, c))
    i
    • 2
    • 3
  • m

    miha-x64

    06/17/2018, 7:06 PM
    Why
    @JvmSynthetic
    is not applicable for classes?
    n
    k
    • 3
    • 6
  • n

    Niels Renard

    06/18/2018, 11:46 AM
    is there some place with examples of functions? I'm looking for an example of https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/reduce-to.html
    i
    • 2
    • 2
  • h

    Hullaballoonatic

    06/19/2018, 12:41 AM
    does overriding a property also override the parent class's get and set methods for that property?
    c
    • 2
    • 1
  • a

    Ayden

    06/19/2018, 4:35 AM
    Guys. Should I get this book
    Kotlin in Action
    ?
    🇳🇴 1
    :yes: 8
    n
    • 2
    • 7
  • h

    Hullaballoonatic

    06/19/2018, 8:49 PM
    say you're adding a bunch of strings into a list. is there a way to duplicate the previous line with the string field highlighted so you can just quickly type in the next string instead of backspacing it out or what not? i'm using intellij
    :google: 2
    e
    • 2
    • 1
  • a

    aromal.s

    06/21/2018, 11:29 AM
    have any one tried running kotlin with node or npm?
    d
    • 2
    • 4
  • t

    thanksforallthefish

    06/21/2018, 2:44 PM
    if I have an interface like
    interface LocalsearchCustomerClient {
    	fun <http://Customer.post|Customer.post>(): Flux<URI>
    }
    and a test using
    Mockito
    like
    @Mock private lateinit var localsearchCustomerClient: LocalsearchCustomerClient
    , can I mock the call somehow? I tried `Mockito.`when`(localsearchCustomerClient.run(any<LocalsearchCustomerClient.() -> Flux<URI>>())).thenReturn(Flux.empty())` but that gives me
    Misplaced or misused argument matcher detected here
    . or, oth, am I trying too hard to use extension functions here? should it just be
    fun post(customer: Customer): Flux<URI>
    ?
    p
    • 2
    • 2
  • h

    Hamza

    06/21/2018, 3:18 PM
    how do i return a method in a
    with
    ?
    p
    c
    • 3
    • 21
  • c

    codyoss

    06/22/2018, 4:01 PM
    What is the difference between
    class Foo<T>(val bar: T)
    and
    class Foo<T: Any>(val bar: T)
    . I don’t understand what the
    : Any
    gets you…
    n
    m
    • 3
    • 4
  • o

    orangy

    06/22/2018, 8:56 PM
    Extension delegating property should work
    ➕ 1
    h
    g
    • 3
    • 20
  • u

    ursus

    06/24/2018, 2:53 AM
    I use dagger2 module, and in java I make all provider methods static for optimizing performance - not creating module instance. How can I make this in kotlin? companion objects always create its instance, or is compiler smart enough to not create the instance if all methods are @jvmstatic?
    m
    • 2
    • 2
  • w

    wineluis

    06/24/2018, 11:16 AM
    how do I convert that to Kotlin?
    g
    • 2
    • 1
  • r

    rjhdby

    06/26/2018, 8:28 AM
    Hello! Can I compile kotlin native into system library like blablalib.so or blablalib.dll? Maybe advise me some tutorial?
    a
    a
    • 3
    • 2
  • g

    Gta

    06/27/2018, 9:23 AM
    can someone tells me if this code is good
    s
    • 2
    • 1
  • d

    Daniele Segato

    06/28/2018, 7:16 AM
    @diesieben07 i don't see how it's the same thing 🙂
    d
    u
    • 3
    • 6
  • r

    Richard Green

    06/28/2018, 12:58 PM
    object M {
        class C (val x: Int, val y: Int = 5)
    }
    
    class N(val x: Int, val y: Int = 5)
    
    fun main(args: Array<String>) {
        val p = N(3)
        val q = (M::C)(3)
    }
    Why is there a syntax error in the val q = line ?
    l
    • 2
    • 1
  • s

    Shawn

    06/29/2018, 4:13 PM
    @Andreas Sinz there’s another function that takes a
    Date
    in place of the long it looks like
    ➕ 1
    a
    • 2
    • 1
  • u

    ursus

    06/29/2018, 10:19 PM
    is there a way I can avoid {} in
    when
    when I dont want the branch to do nothing?
    r
    • 2
    • 1
  • u

    ursus

    06/29/2018, 10:24 PM
    for exhaustivness
    s
    • 2
    • 21
  • k

    karelpeeters

    06/30/2018, 11:50 PM
    That doesn't really matter if you're not using it as an expression, but the last statement in a lambda always is.
    b
    • 2
    • 8
  • b

    briedis

    06/30/2018, 11:51 PM
    Coming from PHP/JS and a bit of Java, Kotlin is really messing me up 😂
    s
    • 2
    • 3
  • c

    crjacinro

    07/02/2018, 4:24 AM
    especially if data classes are open..
    p
    • 2
    • 3
  • o

    oday

    07/02/2018, 8:36 AM
    just gonna do this
    searchResults.sortByDescending {
                        if (it.negotiated_price != null) {
                            100 - ((it.negotiated_price!!.toInt() / it.price) * 100)
                        } else {
                            it.price
                        }
                    }
    s
    n
    • 3
    • 6
  • c

    cart

    07/03/2018, 7:10 PM
    Which channel should I go to if I want to ask questions about building this repo https://github.com/JetBrains/kotlin ?
    i
    • 2
    • 1
Powered by Linen
Title
c

cart

07/03/2018, 7:10 PM
Which channel should I go to if I want to ask questions about building this repo https://github.com/JetBrains/kotlin ?
i

ilya.gorbunov

07/03/2018, 7:34 PM
#kontributors
View count: 2