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

    evkaky

    05/31/2017, 8:08 AM
    guys guys guys I have a string with some text and numbers. And I want to retrieve all numbers from that string via collection’s extension function. How can I do that? I saw documentation, but there are sooo many ext. functions...
    val listOfNumbers = "text 123 and more text 456".someKindOfMap { Regex("\\d+") }
    a
    • 2
    • 1
  • d

    dmitry.kankalovich

    05/31/2017, 1:16 PM
    I just don’t know details of how data classes implemented under the hood, so if I will use Gson to serialize them won’t there be any additional unwanted fields and etc
    j
    • 2
    • 1
  • k

    kagomez

    06/01/2017, 4:59 AM
    so one question have you use that operator in a real project?
    v
    • 2
    • 2
  • t

    tipsy

    06/01/2017, 6:26 PM
    are there any resources anywhere explaining how to release a project with both java and kotlin parts?
    r
    • 2
    • 4
  • o

    orangy

    06/01/2017, 6:50 PM
    Please post articles into #feed
    r
    • 2
    • 1
  • b

    bjornicus

    06/02/2017, 3:58 AM
    anyone happen to know how to read environment variables?
    v
    • 2
    • 2
  • a

    alvico

    06/02/2017, 9:37 AM
    hello, I have a question with data classes, can I use them in standard java libraries for deserialise as pojos, like jakson from fasterxml?
    a
    r
    • 3
    • 6
  • t

    tipsy

    06/02/2017, 7:05 PM
    and how do you typically solve it?
    c
    • 2
    • 4
  • k

    kingsley

    06/03/2017, 7:43 AM
    val handler: Handler = { req, res -> res.body("Hello") }
    Is it bad practice? To declare lambdas? No, it's perfectly fine.
    t
    • 2
    • 8
  • s

    suresh

    06/03/2017, 6:28 PM
    Is there any function in std library to partition a string into Pair. I wanted to created pair from a property string. What i am doing right now is,
    val tuple = "key=value".split("=")
    val pair =  when {
                      tuple.size > 1 -> tuple[0] to tuple[1]
                      else -> tuple[0] to ""
                   }
    d
    o
    • 3
    • 6
  • a

    abanoub.wagdy91

    06/03/2017, 10:36 PM
    Hi Guys i faced the following problem while building gradle Error:Error converting bytecode to dex: Cause: PARSE ERROR: class name (com/pharoslive/views/buttons/RobotoBoldButton) does not match path (com/pharosLive/views/buttons/RobotoBoldButton.class) ...while parsing com/pharosLive/views/buttons/RobotoBoldButton.class note : I am using only kotlin classes it generates this for all kotlin classes please advise
    t
    h
    • 3
    • 9
  • t

    tipsy

    06/04/2017, 8:24 AM
    can you add a secondary constructor to a data-class?
    v
    j
    • 3
    • 3
  • t

    tipsy

    06/04/2017, 10:54 AM
    i'm trying to convert a functional interface to kotlin:
    @FunctionalInterface
    public interface ErrorHandler {
        void handle(Request request, Response response);
    }
    i have
    typealias ErrorHandler = (request : Request, response : Response) -> Unit
    which seems to work fine, except for when i try to call it in java
    error(500, (req, res) -> {
        // return type expected
    });
    can i make this work in both languages somehow? (it used to work fine when the project was all java)
    v
    h
    • 3
    • 4
  • b

    bachhuberdesign

    06/04/2017, 3:45 PM
    Is there point of to init { } in Kotlin for simple declarations? For example: is
    private var disposable: CompositeDisposable = CompositeDisposable()
    any different than
    private lateinit var disposable: CompositeDisposable
    
        init {
            disposable = CompositeDisposable()
        }
    s
    • 2
    • 1
  • k

    kagomez

    06/06/2017, 3:09 AM
    this is the only that I can see but it doesn't mention
    \d
    a
    • 2
    • 2
  • t

    tipsy

    06/06/2017, 4:03 PM
    every time i change any code.
    Do you have incremental builds enabled?
    i can't find that setting
    o
    • 2
    • 6
  • m

    menegatti

    06/07/2017, 9:49 AM
    also we can make some eyes bleed with
    fun <T1 : Any, T2 : Any, T3 : Any, T4: Any, T5: Any, R: Any> safeLet(p1: T1?, p2: T2?, p3: T3, p4: T4, p5:T5, block: (T1, T2, T3, T4, T5) -> R?): R? {
        return if (p1 != null && p2 != null && p3 != null && p4 != null && p5 != null) block(p1, p2, p3, p4, p5) else null
    }
    o
    • 2
    • 3
  • k

    kirillrakhman

    06/07/2017, 1:24 PM
    Alt + Enter, then Right Arrow
    u
    • 2
    • 2
  • e

    evkaky

    06/07/2017, 1:25 PM
    guys, how can I perform complex sort on the collection, like this one in sql:
    ORDER BY name ASC, age DESC
    ? I tried something like this, but second sort function completely override previous order
    persons.sortedBy { it.name }.sortedByDescending { it.age }
    k
    • 2
    • 7
  • e

    elect

    06/07/2017, 2:32 PM
    I have the following:
    rects.sortWith(Comparator { a, b -> ... })
    and I'd like to declare
    Comparator
    somewhere else
    k
    m
    • 3
    • 9
  • w

    witoldsz

    06/07/2017, 7:44 PM
    Looks like everyone is trying to "sell" me the product here 🤔 Well, it seems
    Kotlin = everyone must switch to Idea
    , I mean every team member.
    d
    • 2
    • 1
  • j

    juan.hurtado

    06/07/2017, 10:06 PM
    Would anyone recommend a good starting point to learn kotlin for android ?
    q
    m
    a
    • 4
    • 4
  • m

    miha-x64

    06/08/2017, 9:54 AM
    Is there any way to declare a functional object with parameterized
    invoke()
    ? e. g.
    class SomeAction : ()->?!?!? {
        override fun invoke <T> (): T {
            return ...
        }
    }
    t
    k
    • 3
    • 5
  • e

    elect

    06/08/2017, 4:40 PM
    null as Node?
    did the trick
    s
    • 2
    • 2
  • w

    witoldsz

    06/08/2017, 8:37 PM
    Hi! What would you suggest using to build a Kotlin project? My only requirement is to be able to use external libraries, like jOOQ, Postgres drivers etc… In Java-land almost every lib is available in Maven repository. Can I use libraries from Maven central using Kotlin command line tools? Or should I use Maven or Gradle? What do you use?
    o
    r
    c
    • 4
    • 15
  • a

    akperkins1

    06/08/2017, 8:38 PM
    Hey guys, is there any way in a forEach (on a Map) to skip to the execution of the next element? Akin to Java's "continue" keyword in loops...
    w
    k
    • 3
    • 5
  • i

    iurysouza

    06/09/2017, 1:00 AM
    hey, does anyone knows how to autocomplete the "->" for when expressions in intelij?
    o
    • 2
    • 2
  • v

    vmichalak

    06/09/2017, 6:02 AM
    Hi all, do you know if message: String = "Hello $name" is lazy evaluated by default or not ? It's for optimisation purpose :)
    o
    n
    k
    • 4
    • 13
  • d

    dragas

    06/09/2017, 10:33 AM
    If you were to introduce a bunch of kids with little to no programming background to a programming language, would you pick Kotlin?
    d
    • 2
    • 1
  • s

    s952163

    06/09/2017, 12:41 PM
    Mantas Gridinas If you were to introduce a bunch of kids with little to no programming background to a programming language, would you pick Kotlin? Posted in #getting-startedToday at 7:33 PM
    p
    k
    +2
    • 5
    • 9
Powered by Linen
Title
s

s952163

06/09/2017, 12:41 PM
Mantas Gridinas If you were to introduce a bunch of kids with little to no programming background to a programming language, would you pick Kotlin? Posted in #getting-startedToday at 7:33 PM
p

poohbar

06/09/2017, 2:06 PM
s952163: I most likely would not. Kotlin is very dependent on Java stdlib (collections) and is very tightly coupled to IntelliJ. Which is awesome but it just does too much stuff for a beginner to grasp.
s

s952163

06/09/2017, 2:24 PM
i dont see that as an issue but then u could default to python 🤷
k

kirillrakhman

06/09/2017, 2:26 PM
you don't need to use all of the language features and you can start with http://try.kotlinlang.org/ and put everything at the top-level. this could work ok
d

dalexander

06/09/2017, 2:31 PM
I think one of the most important things in a teaching language is not having to introduce a ton of “magic” up front to make a simple program, and I think Kotlin does okay with that.
e

elizarov

06/09/2017, 2:39 PM
IntelliJ is great for kind. I taught by 10yo daughter Python in PyCharm and Kotlin in IDEA is going to be next. We'll release kotlin script support for Processing.ORG libraries some time soon. This way you can start coding fun stuff in Kotlin with zero boilerplate.
p

poohbar

06/09/2017, 5:55 PM
I think Python is one of the most overrated languages for learning. I don't see how can such an inconsitent language be valuable in any sort of learning. Class declaration is also super messy and the standard lib is awful. Kotlin introduces a whole lot of magic up front. But you could maybe skip the magic parts. Or are you trying to say that
data class
is not magic? If you don't know Java it makes no sense what it actually does.
e

elizarov

06/09/2017, 6:34 PM
You can pick which parts you teach. Look at processing.org, for example. They are based on Java, but choose to teach simpler parts of it
However, Java has a lot of boilerplate just to get you started, so they had to pre-processed their .pde file into valid Java code, which makes them unsuable in all the other Java IDEs without special support.
With kotlin script, on the other hand, it is boilerplatefree out-of-the box.
View count: 3