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
announcements
  • d

    deactivateduser

    08/26/2017, 9:54 PM
    hey kotliners quick question, kotlin enum and jpa @Enumerated annotation I can't seem to find any information on this. In normal Java I use it to specify storing the string value and not ordinal value, but hibernate seems to not like it with kotlin enum
    k
    • 2
    • 4
  • n

    napperley

    08/27/2017, 3:22 AM
    Been trying to get Spek to work but end up with the mysterious/unhelpful Test framework quit unexpectedly message ✨ when running a test via the Spek plugin in IntelliJ.
    j
    • 2
    • 6
  • d

    Dalinar

    08/27/2017, 4:42 AM
    I'm getting an NPE when trying to access my lazy val .. can't debug it either.. the breakpoint doesn't fire, so that seems to explain why the val is not being assigned the lazy result... so my question is, is accessing a lazy val of a subclass called from a constructor of a parent class not supported? ( in my case it is not a direct parent calling the code that ultimately triggers the acccess in the subclass containing the lazy defined property, more like the ultimate parent the one that extends
    Object
    it is a java class, its subclasses are all Kotlin)
    r
    • 2
    • 2
  • a

    alien11689

    08/27/2017, 5:19 PM
    @Danilo Herrera 1) Why did you use MutableCollection? Do you really need mutability? 2) As user of your function I would prefer receiving LotteryResult(...) from pickLottery function, not String. 3) I will add configurable seed for random for future testing 4) Are extension functions really needed? I would prefer e. g. private fun takeRandom(set, count): LotteryState -> LotteryState(setWithoutPicked, pickedNumbers) 5) mayble your functions should be inside class Lottery and only pickLottery should be public?
    d
    • 2
    • 1
  • a

    alien11689

    08/27/2017, 6:44 PM
    Now I would suggest closing LotteryPicker class, There is no need to create specific subclasses.
    d
    • 2
    • 2
  • x

    x80486

    08/28/2017, 12:48 AM
    Suppose I have something like:
    class Client(host: String = "localhost", port: Int = 50551, enableTls: Boolean = false)
    . Now I would like to call the
    constructor
    with a different
    port
    , like:
    val client = HelloWorldClient(443)
    . Is there anything like a "wildcard" or something I can use that fills up the missing parameter? Something like
    val client = HelloWorldClient(_, 443)
    ...
    a
    • 2
    • 3
  • w

    waqas

    08/28/2017, 9:41 AM
    Hi, going through hard part of making kotlin acceptable for our processes. Have to fill a long excel sheet 🙄 with different questions. Is there any resource anybody can point me to which is useful in that context. Like prospects and risks for the language etc. I have this for now: https://docs.google.com/presentation/d/1zYWyDedyf0YhnLFF3TVpUqU3C8PKTuvR5P06L99MRn8/edit?usp=sharing https://plus.google.com/+JakeWharton/posts/WSCoqkJ5MBj Anything more similar to above?
    k
    • 2
    • 1
  • e

    edik

    08/28/2017, 12:42 PM
    Hi guys, given that I needed to declare a fun before referencing it I wondered is the Kotlin grammar LL(k) conformant? Perhaps even LL(1)? in terms of syntax analysis, and is there a grammar reference in some notation available seeing that their isn't a KLS 🙂 ?
    k
    • 2
    • 10
  • r

    rrader

    08/28/2017, 1:16 PM
    is it possible to make when on enum properties?
    k
    • 2
    • 5
  • a

    aaronfox

    08/28/2017, 1:26 PM
    Anyone know under what maven dependency I can find JUnitPlatform.class - ? Listed under how to use spec with maven, but I can't find it on central... 🤔
    h
    t
    • 3
    • 4
  • s

    Slackbot

    08/28/2017, 2:04 PM
    This message was deleted.
    k
    c
    j
    • 4
    • 5
  • a

    ankitdroiddeveloper

    08/29/2017, 2:49 AM
    https://github.com/AnkitDroidGit/Dagger2Retrofit2RxKotlinRxAndroidApplication kotlin project with dagger2
    l
    • 2
    • 1
  • p

    poohbar

    08/29/2017, 7:10 PM
    if (value in listOf(A, B)) { ... }
    and just import
    A
    and
    B
    directly
    k
    • 2
    • 2
  • m

    michaelzinn

    08/30/2017, 8:46 AM
    wasn’t there a way to use enums like ints or something? What was that called?
    k
    • 2
    • 6
  • j

    jstuyts-squins

    08/30/2017, 8:52 AM
    @redrield Based on the code that you show, I think this statement is not true: "And I need the continue statements". You can use `let`:
    taskCache[s]?.let { cachedValue ->
        ...
    }
    k
    • 2
    • 3
  • u

    user

    08/30/2017, 10:36 AM
    message has been deleted
    🎉 6
    n
    • 1
    • 1
  • k

    karelpeeters

    08/30/2017, 12:35 PM
    Idea refactorings should change string references too.
    c
    • 2
    • 1
  • s

    supaham

    08/30/2017, 3:48 PM
    I have the following code:
    data class SquadEntry(
            val name: String,
            var leader: OptionalPresence<UUID> = OptionalPresence.empty(),
            var color: OptionalPresence<String> = OptionalPresence.empty(),
            var tag: OptionalPresence<String> = OptionalPresence.empty(),
            var members: OptionalPresence<Set<UUID>>
    )
    Every time I want to write to a field e.g. leader I have to do leader = OptionalPresence(value). Is there a way to use something like delegate properties to simplify this process?
    v
    • 2
    • 4
  • j

    jw

    08/30/2017, 3:49 PM
    why are you not using nullable types?
    s
    r
    v
    • 4
    • 6
  • r

    rellenberger

    08/30/2017, 5:02 PM
    I am doing a proof of concept of that shows off kotlins features and abilities. What are some areas should I focus on that might get my employer to buy in using Kotlin?
    m
    d
    • 3
    • 2
  • p

    poohbar

    08/30/2017, 7:24 PM
    I am really not convinced by the NPE problems argument. 1. I have rarely if ever had a Java program blow up due to NPE. 2. Kotlin's protection from NPE ends whenever you use platform types. Those are not solved satisfactorily IMO.
    var res = someJavaFuncThatActuallyReturnsNull()
    // res is now SomeJavaType!
    // at this point I can start passing 'res' around and later access anything on it and get an NPE, Kotlin didnt help at all
    s
    a
    +7
    • 10
    • 61
  • d

    Daniel

    08/30/2017, 8:55 PM
    What might be good channel to get feedback on a own project which belongs in the android world, but is not written with the sdk (its for CI with android)? Took Kotlin for a spin to jenkins and now we are represented there as the first(?) or at least currently only plugin written in Kotlin there.
    r
    • 2
    • 1
  • j

    jlleitschuh

    08/30/2017, 9:16 PM
    I'm getting an
    IncompatibleClassChangeError
    on JDK 9 that I'm not expecting. https://travis-ci.org/junit-team/junit5/jobs/270169944#L1267-L1268 I'm not sure why but I seem to be getting it from this test. Any thoughts on why this might occur on JDK 9 but not JDK 8? https://github.com/junit-team/junit5/pull/1001/files#diff-140541d5d08c428c13588c5f777f9218R49
    • 1
    • 1
  • e

    edik

    08/30/2017, 11:29 PM
    "poohbar [20:24] I am really not convinced by the NPE problems argument." - nor am I, this to me seems very overblown, yes in C null pointers are an issue for example but rarely in Java have they arose as something significant in nearly fifteen years working with Java
    k
    • 2
    • 1
  • k

    kevinmost

    08/31/2017, 1:21 AM
    yeah, I've considered how hard it'd be to contribute a compiler flag or something that would make platform types act as nullable. We're using Kotlin in a many-year-old Java codebase at my work, and everyone agrees that platform types are the single most painful part of using Kotlin
    e
    • 2
    • 1
  • a

    asarazan

    08/31/2017, 2:54 AM
    reported https://youtrack.jetbrains.com/issue/KT-20003
  • t

    tianhao

    08/31/2017, 2:59 AM
    Our team had a big discussion around this whether need to use some third party library to do this? I know this is not Kotlin best practices, but I am curiosity to know reason behind
    g
    • 2
    • 5
  • e

    enleur

    08/31/2017, 7:39 AM
    I’m using on production both php and kotlin, and I feel ok 😄
    k
    • 2
    • 1
  • j

    jlleitschuh

    08/31/2017, 4:07 PM
    Has anyone seen this weirdness before? (Javadoc generation for JDK 9)
    :junit-jupiter-api:javadocPicked up _JAVA_OPTIONS: -Xmx500m
    javadoc: error - An exception occurred while building a component: TagInfo
    	(com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: /home/travis/build/junit-team/junit5/junit-jupiter-api/build/classes/kotlin/main/org/junit/jupiter/api/AssertionsKt$sam$Supplier$i$44378ebd.class
      undeclared type variable: T
      Please remove or make sure it appears in the correct subdirectory of the classpath.)
    Please file a bug against the javadoc tool via the Java bug reporting page
    (<http://bugreport.java.com>) after checking the Bug Database (<http://bugs.java.com>)
    for duplicates. Include error messages and the following diagnostic in your report. Thank you.
    com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: /home/travis/build/junit-team/junit5/junit-jupiter-api/build/classes/kotlin/main/org/junit/jupiter/api/AssertionsKt$sam$Supplier$i$44378ebd.class
      undeclared type variable: T
      Please remove or make sure it appears in the correct subdirectory of the classpath.
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:278)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.findTypeVar(ClassReader.java:963)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.sigToType(ClassReader.java:670)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.sigToType(ClassReader.java:732)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.sigToType(ClassReader.java:656)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readType(ClassReader.java:499)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader$11.read(ClassReader.java:1193)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readAttrs(ClassReader.java:1537)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readMemberAttrs(ClassReader.java:1527)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:2391)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:2641)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassBuffer(ClassReader.java:2706)
    	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2719)
    	at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:348)
    	at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:285)
    	at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:633)
    	at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1314)
    	at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:1248)
    https://travis-ci.org/junit-team/junit5/jobs/270479723#L1179
    • 1
    • 6
  • k

    karelpeeters

    09/01/2017, 10:54 AM
    I'm not sure why the second one doesn't work.
    a
    • 2
    • 2
Powered by Linen
Title
k

karelpeeters

09/01/2017, 10:54 AM
I'm not sure why the second one doesn't work.
a

arekolek

09/01/2017, 10:55 AM
Destructuring declarations are only allowed for local variables/values.
~ Preprocessor
k

karelpeeters

09/01/2017, 10:57 AM
Then it's just a language design decision I guess.
View count: 2