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

    maxk

    09/01/2017, 2:16 AM
    dumb question, is there a way to make a superclass for data classes? I'm making a "message passing" architecture where I want a superclass
    Message
    and subclasses are polymorphic data
    f
    b
    13 replies · 3 participants
  • m

    maxk

    09/01/2017, 2:17 AM
    ah, can data classes inherit interfaces
    👍 1
    v
    1 reply · 2 participants
  • z

    zhuxun2

    09/01/2017, 4:34 AM
    Also, is there a Hoogle-like search mechanism/website for Kotlin? https://www.haskell.org/hoogle/
    k
    2 replies · 2 participants
  • t

    techie01

    09/04/2017, 6:38 AM
    how to give projection fields in mongo query in kotlin
    v
    2 replies · 2 participants
  • g

    gjesse

    09/04/2017, 11:40 PM
    or even better:
    >>> fun Int.toHex() = this.toString(16)
    >>> 16.toHex();
    10
    k
    k
    4 replies · 3 participants
  • e

    efemoney

    09/05/2017, 7:15 AM
    Hey everyone, Is there any difference between defining the extention function on the concrete base class as opposed to defining it on a generic subclass ? Semantically, to me, they dont look any different
    fun Context.dpToPx(dp: Int) = ...
    vs
    fun <T: Context> T.dpToPx(dp: Int) = ...
    v
    r
    4 replies · 3 participants
  • e

    elect

    09/05/2017, 6:28 PM
    inline fun <reified T>swizzles(swizzles: Swizzles) {
            when (T) {
                is Vec4b ->
    d
    2 replies · 2 participants
  • v

    voddan

    09/05/2017, 6:32 PM
    when(T) { Vec4b ->
    e
    m
    2 replies · 3 participants
  • m

    mike_shysh

    09/06/2017, 3:04 PM
    Hi, could you recommend some yml to Object parser? Is Jackson the best choice?
    h
    1 reply · 2 participants
  • f

    fmcauley

    09/06/2017, 8:52 PM
    Hello! Does Kotlin have a map function similar to swift?
    a
    2 replies · 2 participants
  • w

    waylonbrown

    09/06/2017, 9:50 PM
    Of course I miss the very last paragraph
    r
    1 reply · 2 participants
  • e

    elect

    09/07/2017, 1:20 PM
    how can I declare an extension parameter
    MAX
    on a generic enum to represent the size? this:
    val <E> Enum<E>.Companion.MAX get() = enumValues().size
    , complains:
    Type arguments for outer class are redundant when nested class is referenced
    1 reply · 1 participant
  • d

    dreamreal

    09/07/2017, 3:03 PM
    What does kotlin-test-junit provide compared to kotlin-test? What advantage would there be in using these against, say, just TestNG in the first place?
    e
    i
    8 replies · 3 participants
  • t

    trevjones

    09/07/2017, 3:15 PM
    sounds good to me just surprised that it worked at all
    k
    1 reply · 2 participants
  • r

    rizwan

    09/07/2017, 3:23 PM
    Is there any course that teaches OOP with Kotlin?
    k
    u
    +1
    5 replies · 4 participants
  • t

    techie01

    09/08/2017, 12:50 PM
    how to become professional kotlin backend developer
    k
    1 reply · 2 participants
  • k

    karelpeeters

    09/10/2017, 6:54 PM
    @trevjones Still works with a default implementation to static method. (I checked the bytecode). I wonder how the Java interop works in this case?
    t
    5 replies · 2 participants
  • b

    benleggiero

    09/10/2017, 6:56 PM
    Why won't this compile?
    val numberOfDoorsIndex = args.indexOf("--numberOfDoors")
        val numberOfDoors: Int
        if (numberOfDoorsIndex > 0 && args.size > numberOfDoorsIndex) {
            val userSetNumberOfDoorsString = args[numberOfDoorsIndex]
            try {
                numberOfDoors = max(3, abs(userSetNumberOfDoorsString.toInt()))
            }
            catch (ex: NumberFormatException) {
                numberOfDoors = 3 // error here
            }
        }
    error:
    Error:(22, 13) Kotlin: Val cannot be reassigned
    Obviously it isn't going to be; if the
    NumberFormatException
    is thrown, it was never assigned in the first place!
    :youtrack: 1
    k
    r
    +1
    6 replies · 4 participants
  • k

    karelpeeters

    09/10/2017, 6:59 PM
    I think you'll get a compile-time error, but it's easy enough to check yourself 🙂
    k
    4 replies · 2 participants
  • w

    waylonbrown

    09/11/2017, 10:33 PM
    Okay so that was my concern, if I do just
    class MyClass(context : Context) {
        var context = context.applicationContext
    then whenever I use
    context
    and command click on it, the IDE takes me to the one referenced in the constructor instead of the field. Is that incorrect and the constructor's context reference isn't held onto?
    k
    5 replies · 2 participants
  • r

    Regan Russell

    09/11/2017, 10:35 PM
    I have data classes that I want to just dump to SQLite3, does SugarORM work for this or is there extremely simple way to persist/retrieve data classes..?
    k
    1 reply · 2 participants
  • e

    elect

    09/12/2017, 9:54 AM
    doesn't work
    infix
    with
    Enum<*>
    ?
    k
    7 replies · 2 participants
  • b

    baob

    09/12/2017, 10:57 AM
    can’t help feeling there should be a way to reduce the duplication of class name.
    m
    4 replies · 2 participants
  • t

    techie01

    09/12/2017, 11:59 AM
    how to get parameters from url
    k
    o
    4 replies · 3 participants
  • n

    nil2l

    09/12/2017, 1:21 PM
    I think for Kotlin learning FP background is even better than Java.
    e
    1 reply · 2 participants
  • z

    ziad

    09/12/2017, 4:17 PM
    You know what’s tricky, remembering which is which (covariance vs contravariance) 😄
    k
    2 replies · 2 participants
  • a

    anstaendig

    09/12/2017, 4:18 PM
    Generics is one of those topics I think I understand and then I am facing a problem and feel like I still don’t
    e
    1 reply · 2 participants
  • b

    bamdmux

    09/12/2017, 4:37 PM
    @ziad The mnemonic for java is PECS (ProducerExtendsConsumerSuper), cause extends marks covariance and super contravariance, if that helps
    z
    4 replies · 2 participants
  • b

    bamdmux

    09/12/2017, 4:38 PM
    In kotlin will be POCI (Producer Out Consumer In) (Not so great)
    b
    2 replies · 2 participants
  • k

    karelpeeters

    09/12/2017, 4:41 PM
    out
    and
    in
    are pretty good names, they match their use cases.
    z
    1 reply · 2 participants
Powered by Linen
Title
k

karelpeeters

09/12/2017, 4:41 PM
out
and
in
are pretty good names, they match their use cases.
z

ziad

09/12/2017, 4:41 PM
Agreed
View count: 1