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

    perryprog

    06/16/2017, 10:07 PM
    How can you use ReactJS with Kotlin? Is that even possible?
    w
    • 2
    • 5
  • n

    nounours

    06/17/2017, 3:37 PM
    Hi, noob question : If I create an
    object
    , does instanciating it two times creates two instances ?
    a
    m
    • 3
    • 6
  • a

    aviran

    06/18/2017, 6:16 PM
    If you could clarify the proper Kotlin syntax for this specific issue.... That would be great
    d
    e
    • 3
    • 3
  • s

    sjthn

    06/19/2017, 8:53 AM
    I am trying custom delegate in kotlin https://try.kotlinlang.org/#/Examples/Delegated%20properties/Custom%20delegate/Custom%20delegate.kt How can i get the value of the variable from within the delegate class?
    v
    a
    • 3
    • 4
  • a

    akbarsha03

    06/19/2017, 11:47 AM
    https://medium.com/codeexplorers/a-quick-look-into-kotlin-preconditions-9a2d53c8c8ca
    v
    • 2
    • 2
  • c

    chalup

    06/20/2017, 10:25 AM
    https://github.com/gradle/gradle/issues/2090
    t
    • 2
    • 1
  • f

    funrep

    06/20/2017, 11:18 AM
    How do I write this kind of pattern in Kotlin?
    while ((line = inp.readLine()) != null) {
                result.append(line)
            }
    d
    v
    • 3
    • 6
  • j

    jordan_k_miles

    06/20/2017, 7:08 PM
    is there a way to make a current java class a data class so I have access to the data class functions? I really only need copy(), so I could probably just make an extension function for it.
    d
    • 2
    • 6
  • j

    jschneider

    06/20/2017, 9:19 PM
    Hey, is there a better way to create properties where getters and setters are protected using a lock? private val lock = ReentrantReadWriteLock() fun getName(): String { lock.readLock().lock() try { return name } finally { lock.readLock().unlock() } }
    d
    n
    • 3
    • 2
  • b

    blindbox

    06/21/2017, 1:40 AM
    Hi. Anyone could tell me what this type means?
    val results: (MutableList<(MutableMap<String!, Any!>..Map<String!, Any!>?)>..List<(MutableMap<String!, Any!>..Map<String!, Any!>?)>?)
    especially the double dots. The function that returns that type was actually returning this java type,
    List<Map<String, Object>>
    v
    d
    k
    • 4
    • 6
  • f

    fjanicki

    06/21/2017, 5:09 AM
    Anyone else got this error :
    error: cannot access NonExistentClass
      class file for error.NonExistentClass not found
      Consult the following stack trace for details.
      com.sun.tools.javac.code.Symbol$CompletionFailure: class file for error.NonExistentClass not found
    1 error
    When trying to use Dagger 2 along with Kotlin?
    v
    • 2
    • 3
  • j

    josebalius

    06/21/2017, 7:46 PM
    @fred.deschenes https://gist.github.com/josebalius/3cd46d3d0dcf0bf57792ac1c512dec1d
    f
    • 2
    • 3
  • d

    diesieben07

    06/22/2017, 9:40 AM
    Only the constants you define are the values of the enum.
    j
    k
    • 3
    • 7
  • s

    sjthn

    06/22/2017, 12:37 PM
    Hi, I am trying this problem https://try.kotlinlang.org/#/Examples/Problems/Index%20of%20Maximum/Index%20of%20Maximum.kt Here is my code
    package maxindex
    
    fun indexOfMax(a: IntArray): Int? {
        if (a.isEmpty())
        	return null
        return a.indexOf(a.max()!!)
    }
    I am getting all tests passed except
    testIndexOfMaximum6
    and
    testIndexOfMaximum7
    . I can't find the bug. Pls help
    m
    • 2
    • 3
  • d

    dalexander

    06/22/2017, 6:48 PM
    Yeah, unfortunately if the existing class doesn’t have a companion method you can’t add companion extension methods 😞
    r
    • 2
    • 9
  • j

    josebalius

    06/22/2017, 6:56 PM
    Hi everyone, quick question, can we use
    when
    with strings? Whenever i try using when with a string i get an error:
    >>> val test = "Hello"
    >>> val test2 = test.replace("lo", "1")
    >>> println(test2)
    Hel1
    >>> when(test2) { 'Hel1' -> println("Hello world") }
    error: incompatible types: Char and String
    when(test2) { 'Hel1' -> println("Hello world") }
                  ^
  • t

    tipsy

    06/23/2017, 5:19 PM
    what's a better way of writing this?:
    class EmbeddedJettyFactory(jettyServer: () -> Server) : EmbeddedServerFactory {
        private var server = Server(QueuedThreadPool(200, 8, 60000))
        init {
            this.server = jettyServer.invoke()
        }
    }
    d
    • 2
    • 7
  • t

    thuanle

    06/26/2017, 8:59 AM
    Hi all, In Java, we can use gradle to point to a specific lib. In kotlin, can we use the same mechanism? How? For example, I have some *.kt extension functions for Android. How can I publish as common libs for other projects to import?
    o
    • 2
    • 2
  • k

    karelpeeters

    06/27/2017, 8:01 AM
    @nkiesel Are you working in a gradle project? If so, you can try updating it in the gradle tab on the right.
    n
    • 2
    • 4
  • t

    tapchicoma

    06/27/2017, 12:46 PM
    how to use extension function from one module tests in another module tests?
    v
    • 2
    • 3
  • j

    joelpedraza

    06/27/2017, 2:24 PM
    @Ruckus where is square bound?
    r
    • 2
    • 1
  • c

    casablancais

    06/27/2017, 2:36 PM
    hi, anyone here tried to use Kotlin Educational Plugin : https://blog.jetbrains.com/kotlin/2016/03/kotlin-educational-plugin/ ?
    a
    • 2
    • 8
  • k

    kevmoturi

    06/27/2017, 3:54 PM
    Oh so currently its another way of loading up kotlin koans 🤔
    c
    a
    • 3
    • 3
  • t

    tulio

    06/27/2017, 7:46 PM
    I'm declaring this extension functions in the same file as the data class, but I'm unable to use them in other classes
    a
    a
    a
    • 4
    • 17
  • s

    skennedy

    06/27/2017, 7:47 PM
    why not just declare the functions in the class?
    t
    • 2
    • 2
  • h

    honghai85592

    06/29/2017, 6:23 AM
    hi everyone, what is difference between companion object and object keyword? tks so much
    j
    v
    +2
    • 5
    • 20
  • m

    marstran

    06/29/2017, 2:22 PM
    Did you create a new project by clicking File -> New -> Project, and choosing Kotlin in the window that popped up?
    t
    j
    • 3
    • 26
  • t

    themodz01

    06/29/2017, 10:22 PM
    I change port...
    k
    • 2
    • 1
  • d

    dasz

    06/30/2017, 9:37 AM
    recyclerView
    does not use its adapter - no run
    getItemCount
    layoutManager
    properly set in
    onViewCreated
    any ideas?
    l
    • 2
    • 3
  • d

    dumptruckman

    06/30/2017, 3:13 PM
    does
    vararg args: Any?
    mean that args is nullable or that null can be accepted as a var arg
    👍 1
    a
    • 2
    • 10
Powered by Linen
Title
d

dumptruckman

06/30/2017, 3:13 PM
does
vararg args: Any?
mean that args is nullable or that null can be accepted as a var arg
👍 1
a

agomez

06/30/2017, 3:16 PM
dumptruckman: it means args can contain nulls
d

dumptruckman

06/30/2017, 3:17 PM
Okay, thanks.
a

agomez

06/30/2017, 3:17 PM
args itself wont be null, if you pass no arg it'll be an empty collection
d

dumptruckman

06/30/2017, 3:18 PM
what if i called the function with
args = null
?
a

agomez

06/30/2017, 3:23 PM
in that case args is an array with just 1 element
and that element is null
``````
fun test(vararg args: Any?) {
    println(args.size)
}

fun main(args: Array<String>) {
    test(args = null)
}
prints 1
d

dumptruckman

06/30/2017, 3:25 PM
hmm ok, thanks
View count: 2