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

    Seba

    11/02/2017, 5:29 AM
    hello folks.... I want to start with Kotlin.. so I decided to install Android Studio3.1 ...in my linux box, so after a couple of workarounds, the most closer I'm to boot up android Studio I get is "Error: Could not find or load main class com.intellij.idea.Main".... some clue about where to look for ? thanks in advance , and sorry if its not the right channel
    k
    • 2
    • 12
  • f

    fred.deschenes

    11/03/2017, 2:45 PM
    you'd have to declare your interfaces like this :
    interface Wtf<out A, out B, out C : Ftw<A, B>>
    interface Ftw<out A, out B>
    👍 1
    m
    • 2
    • 4
  • n

    Nathan Desmet

    11/03/2017, 2:53 PM
    Is there a way to compile a kotlin class without including the kotlin.Metadata annotation, because its value still exposes class information after obfuscation. (The code i’m compiling will not be used as a library, and doesn’t use kotlin-reflect)
    m
    • 2
    • 6
  • s

    Sudhir Singh Khanger

    11/03/2017, 3:41 PM
    println("item at $index is ${items[index]}")
    What is the role of curly and square brackets in the above example?
    d
    • 2
    • 2
  • p

    pastjean

    11/03/2017, 3:44 PM
    https://kotlinlang.org/docs/reference/basic-types.html#string-templates <- here the doc
    s
    • 2
    • 1
  • c

    cconstable

    11/03/2017, 7:31 PM
    👋 Hi all, new to Kotlin and I'm having trouble understanding why the
    ->
    is used to specify return types in some cases but not others (e.g.
    :
    is used in
    fun
    ). Is there a reason for this perceived inconsistency?
    k
    p
    • 3
    • 3
  • c

    CodeCrazy99

    11/04/2017, 4:05 AM
    Nice to find a kotlin community though, I'm learning Java and found kotlin to be the latest so learning both now
    ➕ 3
    ✌️ 1
    a
    b
    • 3
    • 2
  • k

    kristofdho

    11/05/2017, 2:45 PM
    or actually
    .pairwise()
    , even better (also 1.2)
    i
    • 2
    • 2
  • s

    Slackbot

    11/06/2017, 3:58 PM
    This message was deleted.
    e
    t
    +3
    • 6
    • 14
  • a

    Andreas Sinz

    11/06/2017, 5:42 PM
    @Jorrit the code is here https://github.com/Kotlin/kotlin-koans/blob/master/src/i_introduction/_1_Java_To_Kotlin_Converter/JavaCode1.java
    j
    • 2
    • 1
  • a

    adrik77

    11/06/2017, 6:57 PM
    something like this?
    val list1 = listOf("a", "b")
        val list2 = listOf(1,2,3)
        val cartesianProduct = list1.map { e1-> list2.map { e2-> e1 to e2 } }.flatten()
    o
    h
    p
    • 4
    • 3
  • e

    elaborate tissue

    11/07/2017, 6:48 AM
    so that it returns the flat mapped elements as well as the remaining > n elements
    o
    i
    • 3
    • 6
  • w

    wineluis

    11/08/2017, 10:41 AM
    how can I set the type here to accept any class that implements LAObject?
    var clazz: Class<LAObject>? = null
    d
    • 2
    • 2
  • s

    Sandm

    11/08/2017, 8:52 PM
    I have such string: [["9.00"],[],[],[],[]], how do I turn it into list or array?
    k
    b
    +2
    • 5
    • 12
  • j

    jamie-purchase

    11/09/2017, 7:38 PM
    Hi everyone - sorry if i'm not posting in the right place, i'm new here Jamie, live in Galway, Ireland - been experimenting with Kotlin for a short while now loved Java for years and still use it alot but loving the less-verbose and sexier Kotlin syntax anyway, I have a question about casting a value from a java method to a HashMap and i've exhausted my google-fu 😕 calling
    getAttribute("something")
    on an instance of
    com.sun.net.httpserver.HttpHandler
    and I need to cast it to
    HashMap<String, Any>
    but i'm unfamiliar with how to do that
    p
    k
    • 3
    • 12
  • d

    diegog

    11/10/2017, 6:29 PM
    @elect where you looking for something like that?
    e
    • 2
    • 1
  • s

    shodan45

    11/10/2017, 8:39 PM
    if I'm starting a new kotlin project in intellij, what "type" of project should I pick?
    p
    d
    • 3
    • 5
  • k

    karelpeeters

    11/10/2017, 9:18 PM
    Are you sure you even needed it? I think it should work without one too.
    s
    • 2
    • 1
  • k

    karelpeeters

    11/11/2017, 9:12 AM
    Like this: https://kotlinlang.org/docs/reference/generics.html
    c
    • 2
    • 8
  • s

    scottc

    11/13/2017, 2:09 AM
    I know thanks 🙂 . The reason I'm using the online version is that I couldn't figure out how to run individual tests in IntelliJ
    a
    • 2
    • 3
  • r

    Ruckus

    11/13/2017, 6:38 PM
    @jamie-purchase I would recommend the official guide (https://edvin.gitbooks.io/tornadofx-guide/content/). If you have any questions, the #tornadofx channel is a great place to ask. @edvin also has a number of useful videos on his channel: https://www.youtube.com/user/MrEdvinsyse/videos
    👍 1
    j
    • 2
    • 4
  • a

    amatos

    11/14/2017, 1:44 AM
    I have a question: if I have a
    person
    class that has
    district
    and district has a
    region
    and region has a
    country
    , how should
    person
    have the reference to district? atm I have it like:
    var district:District?=null
    a
    • 2
    • 1
  • e

    elye

    11/14/2017, 2:45 PM
    https://medium.com/@elye.project/mastering-kotlin-standard-functions-run-with-let-also-and-apply-9cd334b0ef84
    👍 3
    m
    • 2
    • 5
  • k

    kevin_abrioux

    11/14/2017, 5:52 PM
    Hi all, with java, i have this syntax
    MainActivity.this
    what is the equivalent in Kotlin ?
    e
    • 2
    • 2
  • t

    Trevor

    11/14/2017, 8:13 PM
    Yeah I just want the compiler to catch all my mistake for me, and this seemed like a real easy case for the compiler to check that for me
    p
    • 2
    • 4
  • s

    shamrock_frost

    11/15/2017, 7:01 AM
    Why doesn't this give me
    null
    ?
    sealed class E {
        data class A(val string : String) : E()
        sealed class B : E() {
            data class C(val int : Int) : B()
        }
    }
    
    val x : MutableList<E> = mutableListOf(E.A("a"), E.B.C(1))
    println(x as? MutableList<E.B>)
    b
    • 2
    • 1
  • v

    viliusk

    11/15/2017, 1:30 PM
    How do you do searches on :android: from EditText on your API? I’m trying to use Rx for that: https://kotlinlang.slack.com/archives/C0B8Y8BHC/p1510752244000312
    m
    • 2
    • 2
  • h

    holgerbrandl

    11/16/2017, 1:28 PM
    Hmm, I could use
    let
    , but I actually would like to use a non-extension function on my argument:
    (listOf(1,2)).let { (x, y) -> x+y} //works
    somefun(listOf(1,2)) { (x, y) -> x+y}  //want that
    d
    k
    • 3
    • 8
  • r

    Rafael Schneider

    11/17/2017, 1:05 AM
    I like to colaborate developing and translating some documentation to portuguese language. I'm braziliam... 😉
    d
    • 2
    • 2
  • e

    elect

    11/17/2017, 9:21 AM
    val console = object { fun draw() }
    fun a() = console.draw() // error draw unresolved
    f
    o
    • 3
    • 5
Powered by Linen
Title
e

elect

11/17/2017, 9:21 AM
val console = object { fun draw() }
fun a() = console.draw() // error draw unresolved
f

Fré Dumazy

11/17/2017, 9:33 AM
you must define a body for
draw()
in the first line
val console = object { fun draw() { } }
e

elect

11/17/2017, 9:35 AM
it does have
I didn't report in the example
o

orangy

11/17/2017, 11:50 AM
That doesn’t work, because
console
is public, and we don’t have any (named) type to expose to other modules. Make it internal, and it should work.
View count: 2