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

    nathanchere_slack

    12/19/2017, 8:40 AM
    sorry for the stupid noob question but i can't find any answer when running kotlin scripts via
    kotlinc --script
    how do you include/import/whatever another file like if i want to have a
    common.kts
    v
    • 2
    • 4
  • k

    karelpeeters

    12/19/2017, 1:17 PM
    If it's really just for simple tests can't you use
    assert(a == b) { "a wasn't equal to b" }
    from the stdlib?
    n
    • 2
    • 11
  • n

    nathanchere_slack

    12/19/2017, 3:04 PM
    FYI if anyone else comes asking about kscript, this has either answered or lead me on the right track to answers for most of my questions: https://resources.jetbrains.com/storage/products/kotlinconf2017/slides/kscript.pdf
    j
    • 2
    • 1
  • v

    voddan

    12/20/2017, 5:11 PM
    message has been deleted
    a
    • 2
    • 2
  • t

    timurnav

    12/20/2017, 11:12 PM
    I tried to use
    (0 until list.size - 1). filter{ list[it] == list[it + 1] }
    but it doesn't work for case
    333
    ->
    33
    Do I not undestand smthng?
    p
    • 2
    • 3
  • x

    xenoterracide

    12/21/2017, 10:10 AM
    does kotlin have a postfix if? eg.
    doThing() if true
    e
    • 2
    • 1
  • w

    warren

    12/22/2017, 12:56 AM
    I invalidated my caches and restarted, still the same.
    v
    p
    • 3
    • 4
  • o

    oday

    12/24/2017, 11:50 AM
    hm! I didn’t know you could do the array literal
    [ ]
    instead of
    arrayOf
    a
    a
    • 3
    • 6
  • o

    oday

    12/26/2017, 3:29 PM
    anyone familiar with the Strategy pattern?
    k
    • 2
    • 1
  • o

    oday

    12/26/2017, 5:14 PM
    and I wanted to see if this is the best way to do such a thing, or does Kotlin facilitate the purpose of this pattern more easily
    a
    • 2
    • 11
  • c

    coder

    12/28/2017, 7:05 PM
    Is Kotlin easy to learn then Java?
    d
    l
    • 3
    • 3
  • x

    xenoterracide

    12/28/2017, 7:44 PM
    listOf(
        "is",
        "sec",
        "changeset",
        "reg",
        "fileuploads"
        /*
        "pdf",
        "user-authn"*/
    ).forEach { if (file("lib/" + it).exists()) includeBuild("lib/" + it) }
    I want to rewrite this to simply list lib, and then do the needful
    d
    • 2
    • 6
  • j

    James Coggan

    12/29/2017, 10:09 AM
    Based on the question above, I wonder if soon people will learn Kotlin instead of java . I have a friend that works in construction and was thinking what was the best to teach him, since the Kotlin tutorials usually compare the code to java
    k
    e
    +2
    • 5
    • 11
  • d

    Dagan Sandler

    01/01/2018, 8:28 AM
    Hi, I have a question regarding Kotlin Koans: Collections: Max min - I'm trying this solution:
    fun Customer.getMostExpensiveOrderedProduct(): Product? = orderedProducts.maxBy { it.price }
    but it's failing and I'm not sure why. The test error is
    Expected: null
    Actual: null
    , so that's not really helpful to find out the problem
    • 1
    • 1
  • t

    Tristan Wiley

    01/02/2018, 2:48 AM
    As of now that's the correct way to do it. The team has noted they're planning on adding it, but it's been on the table since 2014 so we'll see 🙂
    😮 1
    l
    • 2
    • 1
  • b

    bartosz.malkowski

    01/04/2018, 9:40 AM
    I'm not sure if creating Handler object is best way to do that
    k
    • 2
    • 2
  • r

    RandomBK

    01/08/2018, 3:22 AM
    Hi All, is there any way to create a class that implements the same interface multiple times with two generic parameters, where one parameter is a subclass of the other? i.e.
    interface A
    interface MutableA : A
    
    interface Container<out E> : List<E>
    interface MutableContainer<out MUTABLE : READ, out READ> : Container<READ>, MutableList<MUTABLE>
    h
    • 2
    • 1
  • m

    mwerschy

    01/08/2018, 9:30 AM
    @RandomBK What are you trying to acomplish? How would usage of this class look?
    r
    • 2
    • 1
  • a

    actsasgeek

    01/08/2018, 5:05 PM
    is there anyone coming to Kotlin from Clojure? 😮
    😎 1
    b
    c
    • 3
    • 3
  • m

    Michael

    01/09/2018, 3:13 PM
    We switched to Intellij. 😉
    😂 1
    s
    • 2
    • 1
  • c

    chadmorrow

    01/09/2018, 11:19 PM
    Hi all. I'm new to Kotlin, coming from the javascript world. I've primarily only worked with javascript, node, react, etc. and while I feel I've got a pretty decent grasp of all of that, I'm in a job now where I need to use Kotlin. Most of the learning resources I've found have been from the perspective of java programmers or android programmers. Does anyone have any resources that aren't written from that perspective? Also, are there any resources written for folks coming from javascript?
    👍 1
    k
    i
    • 3
    • 2
  • j

    jp

    01/10/2018, 10:49 AM
    no such way available. I’m setting textView.text = “” but unable to do so for TextColor
    k
    • 2
    • 1
  • k

    karelpeeters

    01/10/2018, 11:01 AM
    You should still be able to just call the setter exactly like you would in Java.
    j
    • 2
    • 5
  • k

    karelpeeters

    01/10/2018, 6:55 PM
    for ((index, entry) in map.entries.withIndex()) { ... }
    would work if you really need it.
  • c

    cedric

    01/11/2018, 11:28 PM
    @chb0kotlin
    interface Populace {
       val people: Set<People>
    }
    c
    • 2
    • 7
  • s

    sodiqoladeni

    01/12/2018, 2:49 AM
    Hi everyone, have decided to learn Kotlin but im unable to see a tangible pdf online that talk about kotlin without using it for Android, who has a good pdf (like head first kotlin) to start with or link to online resources that that teaches normal programming in kotlin. Regards
    h
    c
    g
    • 4
    • 23
  • e

    edwardwongtl

    01/12/2018, 3:20 AM
    As I remember
    .()
    lambda with receiver
    h
    c
    • 3
    • 4
  • j

    Joaco

    01/13/2018, 4:14 PM
    Hello all!! I have one question about TDD on Kotlin, in my case, in java, my stack to do TDD is jUnit + Mockito, and Rest-assured when have to test Rest services. In case of kotlin, is a good aproach this stack or are better other test framework?
    a
    f
    +3
    • 6
    • 6
  • s

    Shawn

    01/15/2018, 5:55 AM
    @Max Russek would you mind providing a code sample?
    m
    • 2
    • 1
  • p

    poohbar

    01/15/2018, 7:09 PM
    Aren't top-level functions scoped to the file they are defined in?
    r
    • 2
    • 1
Powered by Linen
Title
p

poohbar

01/15/2018, 7:09 PM
Aren't top-level functions scoped to the file they are defined in?
r

russhwolf

01/15/2018, 7:18 PM
Only if you mark them
private
. By default they’re visible globally.
View count: 4