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

    rook

    10/16/2017, 8:55 PM
    so, if I have a Java class with three constructors that I’m extending, is there a way to call a different
    super
    constructor based on the parameters supplied?
    r
    • 2
    • 2
  • s

    strelok

    10/17/2017, 1:55 AM
    can somebody explain why
    Iterable<T>.all(...)
    returns
    true
    if the collection is empty?
    a
    • 2
    • 1
  • d

    dhf

    10/17/2017, 10:13 AM
    What is the best way to interop with MacOS / Cocoa from Kotlin Native? I only found https://github.com/udalov/kni which seems to be discontinued. Thanks in advance for some hints.
    m
    • 2
    • 2
  • l

    leonardootto

    10/17/2017, 9:19 PM
    *. become (.+?)\\. and *. become \1
    g
    • 2
    • 3
  • a

    alex.krupa

    10/18/2017, 7:15 AM
    @groostav Take a look at https://github.com/VerbalExpressions/KotlinVerbalExpressions, seems pretty nice for readability.
    😮 1
    k
    g
    • 3
    • 2
  • n

    nil2l

    10/18/2017, 7:38 AM
    Is there a way to shorter this
    listOf(1) + listOf(2,3,4,5)
    . Something like this
    1 :: listOf(2,3,4,5)
    .
    k
    • 2
    • 12
  • e

    edwardwongtl

    10/18/2017, 8:48 AM
    Check if
    t
    is
    Iterable
    inside your
    concat
    , and skip the
    listOf(t)
    is true
    k
    n
    • 3
    • 18
  • r

    rmarinsky

    10/18/2017, 9:04 AM
    Hi all May be I'm not perfectly google it But why when do I create Gradle with Koltin project, automatically generated java packages in main and test modules?

    https://i.imgur.com/MMLBe47.png▾

    r
    • 2
    • 7
  • p

    Paul Woitaschek

    10/18/2017, 6:36 PM
    On the browser it’s there but not on mobile
    k
    • 2
    • 1
  • m

    Marc Knaup

    10/18/2017, 7:30 PM
    Hey guys, is there a way to tell the compiler to not accept generic types as reified type argument?
    inline fun <reified Value : Any> test1(): Value = TODO()
    inline fun <reified Value : Any> test2(): List<Value> = TODO()
    
    val test: List<Int> = test1()
    In the example using
    test1()
    (accidentally instead of
    test2()
    ) should raise an error because I cannot get the generic type of the
    List
    anyway.
    r
    m
    +2
    • 5
    • 14
  • j

    joelpedraza

    10/18/2017, 8:45 PM
    bar(::foo)
    is an unresolved reference however, receievr type mismatch
    k
    • 2
    • 4
  • p

    Paul Woitaschek

    10/18/2017, 8:56 PM
    And you can't see it when zoomed to fill the form
    a
    • 2
    • 1
  • t

    tianhao

    10/19/2017, 3:24 AM
    The warning is :
    Kotlin: Unchecked cast: Array<out Validator> to Array<Validator>
    g
    • 2
    • 4
  • t

    tianhao

    10/19/2017, 5:34 AM
    @jw this is java way and it works
    return list.stream().allMatch(new HashSet<>()::add);
    i
    • 2
    • 8
  • u

    540grunkspin

    10/19/2017, 8:49 AM
    @elizarov Yeah i guess. My reason for wanting this is actually for the android data binding where i need to call notifyPropertyChanged in order to update the view. I guess it is technically not a data class then but it is more or less just holding on to data.
    d
    • 2
    • 1
  • o

    Olekss

    10/19/2017, 9:06 AM
    And another question - but I guess you more in coroutines than collections -> One "pain" I see in Kotlin is that if it uses vals on collections, it still is the same underlying java collection under the hood, and no possibility to use structural sharing when doing operations on collections - what Clojure does... so definitely there is performance loss whenever doing operations on immutable collections
    g
    • 2
    • 3
  • o

    Olekss

    10/19/2017, 10:01 AM
    Roman, and do I understand correctly that when writing my suspend function which actually establishes remote connection (Socket?) and does some query, I need to finally wrap it into suspendCoroutine(continuation ->) or suspendCancellableCoroutine - where exactly I doo the work, and then call the continuation result when I am done?
    e
    • 2
    • 3
  • j

    jlleitschuh

    10/19/2017, 9:22 PM
    Is there a good way to get the version of kotlin programmatically from within java/kotlin/groovy code??
    i
    • 2
    • 2
  • d

    domfox

    10/20/2017, 1:37 PM
    I considered something along the lines of
    inline fun <reified T, R> Class<T>.reifyIn(f: () -> R): R = f()
    but it didn't appear to help
    m
    • 2
    • 1
  • p

    pavel

    10/20/2017, 5:41 PM
    @lynas https://kotlinlang.org/docs/reference/compiler-plugins.html#no-arg-compiler-plugin might be a better solution to your problem
    👍 1
    l
    • 2
    • 1
  • n

    nkiesel

    10/20/2017, 9:32 PM
    I would like to delegate properties to other properties instead of providing getter and setter, is that possible? Perhaps using
    val x by y.z
    syntax? A concrete example is the following
    interface A {
        val a: String
    }
    
    class AImpl : A {
        override val a = "hello"
    }
    
    interface B {
        var b: Int
    }
    
    class BImpl : B {
        override var b = 42
    }
    
    class C : A, B {
        private val _a = AImpl()
        private val _b = BImpl()
    
        // override val a by _a.a
        override val a
            get() = _a.a
    
        // override val b by _b.b
        override var b
            get() = _b.b
            set(v) { _b.b = v }
    }
    
    fun main(args: Array<String>) {
        val c = C()
        c.b = 11
        println("a=${c.a} b=${c.b}")
    }
    k
    • 2
    • 1
  • r

    rrva

    10/23/2017, 2:48 PM
    Will there be KotlinConf live streaming?
    t
    h
    • 3
    • 2
  • m

    myanmarking

    10/23/2017, 3:23 PM
    guys does any1 here uses evernote job manager? need an advice
    k
    • 2
    • 1
  • k

    karelpeeters

    10/23/2017, 10:33 PM
    Kotlin enums definitely extend
    java.lang.Enum
    , can you post your code and error message?
    g
    • 2
    • 1
  • k

    karelpeeters

    10/24/2017, 10:39 AM
    Publisch you project as a maven artifact and have you users include the dependencies like that, or build a fat jar.
    a
    • 2
    • 5
  • m

    myanmarking

    10/24/2017, 11:12 AM
    guys does any1 know if there is a way to insert some rows in Room Db without triggering the Flowable observable?
    k
    • 2
    • 1
  • g

    Geir

    10/24/2017, 7:24 PM
    I have created a Kotlin enum and need to pass it's Java Class equivalent to `org.neo4j.ogm.typeconversion.EnumStringConverter`'s (Java library) constructor. This constructor takes a
    Class<? extends Enum>
    , which I cannot figure out how to get from my Kotlin enum. I've tried
    MyEnum
    ,
    MyEnum.javaClass
    and
    MyEnum::class
    all with/without companion object on MyEnum, all with different compile errors. How do I get MyEnum's
    java.lang.Class<? extends java.lang.Enum>
    ?
    a
    k
    • 3
    • 3
  • c

    cody

    10/24/2017, 7:41 PM
    Has anyone ran into issues with
    @property
    when writing KDoc? Using the Kotlin plugin for Android Studio it appears to break the generation of documentation for the tooltip window. Essentially everything after
    @property
    does not display. Sorry if this has already been discussed, I looked through the channel but didn’t see it popup
    t
    • 2
    • 2
  • d

    DanielVF

    10/24/2017, 8:45 PM
    I'm totally new to Kotlin - I just installed IDEA and created a new Kotlin JS project. Unfortunately, I can't build due to this bug: https://youtrack.jetbrains.com/issue/KT-20650#tab=History How do I use the beta plugin that this is fixed in?
    b
    • 2
    • 2
  • g

    groostav

    10/24/2017, 8:55 PM
    i need to convert that into the value
    cos( .75 + pi)
    == 0.9976...
    m
    • 2
    • 1
Powered by Linen
Title
g

groostav

10/24/2017, 8:55 PM
i need to convert that into the value
cos( .75 + pi)
== 0.9976...
m

mzgreen

10/25/2017, 6:08 AM
Seems similar to the reversed polish notation, you could parse it pretty easily using stack data structure. https://en.wikipedia.org/wiki/Reverse_Polish_notation
👍 1
View count: 2