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

    cedric

    05/05/2017, 9:57 PM
    I see what you did there
    😬 1
    e
    • 2
    • 5
  • p

    poohbar

    05/06/2017, 12:58 AM
    I need to pass
    this
    into one of the properties I have in my class.. is there anything better or more idiomatic I could do than:
    class Main {
        lateinit var manager: Manager
        
        init {
            manager = Manager(this)
        }
    }
    u
    • 2
    • 1
  • p

    poohbar

    05/06/2017, 4:07 PM
    But Kotlin's
    partition()
    is just another useless
    groupBy()
    c
    • 2
    • 2
  • p

    poohbar

    05/07/2017, 12:40 PM
    Ok I think this should work:
    fun <T> T.debug(): T {
        println(this)
        return this
    }
    👍 5
    o
    d
    • 3
    • 3
  • e

    evkaky

    05/10/2017, 3:57 PM
    guys, I need to emulate java static method in my kotlin code. I tried to use compain object, but seems it’s a wrong choice:
    class MyClass {
    	companion object {
    		fun myCoolStaticMethod() {
    
    		}
    	}
    }
    Java library (junit 5), which expects existing of static method myCoolStaticMethod tell me, that there is no such method in MyClass What I’am doing wrong?
    k
    j
    • 3
    • 5
  • p

    poohbar

    05/10/2017, 7:37 PM
    because getters and setters are also just a convention..
    e
    • 2
    • 3
  • s

    stoyicker

    05/12/2017, 12:36 PM
    now that I think about it, it should probably be _ -> true, but the problem is there regardless
    a
    • 2
    • 8
  • d

    deinspanjer

    05/12/2017, 3:30 PM
    If a method calls for an Array<Any> and I have an Iterable, how can I turn it into an Array?
    k
    • 2
    • 2
  • p

    poohbar

    05/12/2017, 4:43 PM
    it seems like that if I do
    val t: Target = Target(...)
    before I have defined the class
    Target
    it assumes it is the annotation instead of sayin it is unresolved.
    u
    • 2
    • 1
  • d

    deinspanjer

    05/12/2017, 5:45 PM
    Um.. this is an parameter to a method.
    m
    • 2
    • 1
  • p

    poohbar

    05/12/2017, 8:38 PM
    in this lambda
    { x: Int, y: Int -> x + y }
    we can explicitly specify the type of parameters. Can we also specify the return type?
    a
    • 2
    • 1
  • m

    moltendorf

    05/15/2017, 5:31 AM
    I feel there's a way to simplify this, no?
    val squares = squares.dropWhile { it.area < id - it.area }.take(2)
    val previous = squares.first()
    val current = squares.last()
    e
    • 2
    • 3
  • c

    cedric

    05/15/2017, 2:45 PM
    If you only take the first two that satisfy the predicate, isn't it wasteful to filter the whole list?
    e
    • 2
    • 2
  • n

    noctarius

    05/18/2017, 4:49 AM
    @marcpires anyone with [JB] in the name, you can ask @hhariri to help out too 🙂
    h
    m
    • 3
    • 6
  • r

    roee

    05/18/2017, 7:27 AM
    any good video courses ? preferably for free
    👍 1
    v
    • 2
    • 1
  • m

    mrtreinis

    05/18/2017, 1:14 PM
    I need to invoke a method via Java reflection, and I am trying to pass array of values to invoke(object, args) but args is not acceptes as args, but instead passed on to the method
    r
    • 2
    • 1
  • m

    maciekjanusz

    05/18/2017, 1:31 PM
    the question is whether
    Int
    and
    Int?
    compile to one or different class files
    n
    • 2
    • 3
  • o

    orangy

    05/18/2017, 1:33 PM
    Specifically for primitive, it may differ, nullable
    Int?
    is always
    Integer
    , but non-null
    Int
    can be either
    Integer
    or
    int
    m
    • 2
    • 2
  • m

    maciekjanusz

    05/18/2017, 1:38 PM
    which
    @Nullable
    /
    @Nonnull
    are those? usually these don't have runtime retention, so I guess it's still not possible to infer nullability using reflection, no?
    d
    • 2
    • 1
  • d

    diesieben07

    05/18/2017, 2:42 PM
    Unit is like Java's void
    r
    • 2
    • 5
  • a

    antonioleiva

    05/18/2017, 4:00 PM
    The digital Ed is up to 1.0.6. I'm in the process to update it to 1.1, but everyone will receive the update when it's ready
    👍 2
    v
    b
    • 3
    • 3
  • m

    moltendorf

    05/18/2017, 8:55 PM
    Erm, sorry extension interfaces/classes*
    u
    • 2
    • 3
  • r

    rahulsom

    05/19/2017, 2:24 AM
    I have this java interface
    public interface AggregateType<AggregateIdT> {
        AggregateIdT getId();
    }
    I wrote this in my kotlin class
    data class Patient(val id: String, val identifier: String): AggregateType<String>
    I'm assuming that kotlin would provide me a
    getId()
    method. However, I get this error:
    Class 'Patient' must be declared abstract or implement abstract member public abstract fun getId(): String!
    When I do try to implement it like this:
    data class Patient(val id: String, val identifier: String): AggregateType<String> {
        override fun getId() = id
    }
    I get a Platform Declaration clash.
    b
    • 2
    • 1
  • r

    rahulsom

    05/19/2017, 2:24 AM
    What's the right way to extend that java interface in kotlin?
    • 1
    • 1
  • c

    conner

    05/19/2017, 4:44 AM
    dependencies {
        compile "org.jetbrains.kotlin:kotlin-stdlib-jre8"
    }
    b
    • 2
    • 2
  • c

    conner

    05/19/2017, 4:58 AM
    Thank you so much @cedric! I'm sorry for wasting your time, I'm coming from Python and have never used any Java build tools.
    b
    • 2
    • 14
  • l

    leodeleon

    05/19/2017, 6:09 AM
    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'
    ...
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
        testCompile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
        compile 'com.google.dagger:dagger:2.10'
        kapt 'com.google.dagger:dagger-compiler:2.10'
    b
    • 2
    • 1
  • p

    pkworlz

    05/19/2017, 7:34 AM
    how setup things in linux
    d
    • 2
    • 1
  • c

    codebeast

    05/19/2017, 8:01 AM
    Hey guys! Happy to be here 🙂 I have a JavaScript background and finding it difficult understanding the delegation concept as seen in the docs here:
    class Person(val name: String) {
        constructor(name: String, parent: Person) : this(name) {
            parent.children.add(this)
        }
    }
    and here:
    class MyView : View {
        constructor(ctx: Context) : super(ctx)
    
        constructor(ctx: Context, attrs: AttributeSet) : super(ctx, attrs)
    }
    Wondering if I could get a clearer description of what happens. Thanks
    m
    k
    • 3
    • 5
  • c

    codeinbit

    05/19/2017, 8:52 AM
    Hi Guys, I'm new here 🙂 I've decided to pick up Android development and I want to do that with Kotlinlang. I was wondering if anyone could give me a guild/heads up. Thanks.
    v
    • 2
    • 2
Powered by Linen
Title
c

codeinbit

05/19/2017, 8:52 AM
Hi Guys, I'm new here 🙂 I've decided to pick up Android development and I want to do that with Kotlinlang. I was wondering if anyone could give me a guild/heads up. Thanks.
v

vincentloi

05/19/2017, 8:53 AM
codeinbit: Yes. A good selection of links here that we’ve been sharing - https://kotlin.link/. Ask can me if need help 🙂
👍 3
c

codeinbit

05/19/2017, 8:55 AM
Thank you @vincent. I will check it out.
View count: 2