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

    Slackbot

    02/07/2019, 1:05 PM
    This message was deleted.
    k
    • 2
    • 1
  • c

    czuckie

    02/07/2019, 2:54 PM
    could just use
    config.isTransparentToolbar() == true
    iirc
    a
    • 2
    • 1
  • a

    adam-mcneilly

    02/07/2019, 2:56 PM
    huh == Boolean.TRUE made it go away
    s
    k
    l
    • 4
    • 26
  • d

    dumptruckman

    02/07/2019, 4:11 PM
    var recipients: MutableList<String> = mutableListOf()
        var recipient: String
            set(recipient: String) {
                recipients.add(recipient)
            }
    a
    • 2
    • 1
  • d

    dumptruckman

    02/07/2019, 4:23 PM
    that would expose the property as a public field though, right?
    s
    • 2
    • 3
  • d

    dumptruckman

    02/07/2019, 4:53 PM
    is it possible to use a property for ONLY setting another property - like it has no getter in java or kotlin
    d
    • 2
    • 1
  • d

    diesieben07

    02/07/2019, 4:55 PM
    var foo: String
        @JvmSynthetic
        @Deprecated(message = "unused getter", level = DeprecationLevel.HIDDEN)
        get() = throw RuntimeException()
        set(value) {
            
        }
    r
    • 2
    • 1
  • d

    dumptruckman

    02/07/2019, 6:13 PM
    Does Kotlin have any secret feature for automatically overriding the return type of builder methods in subclasses?
    s
    • 2
    • 17
  • m

    Michael

    02/07/2019, 8:11 PM
    I have a lambda and I’m trying to have it return null from within an if statement; but it seems that it just exits the if and moves on to the last line:
    { .....some lines.... if (condition) { null } ..... final value }
    d
    k
    g
    • 4
    • 6
  • g

    groostav

    02/07/2019, 8:40 PM
    hey, can I have this?
    sealed inline class Token{}
    object UnixNewline: Token()
    object WindowsNewline: Token()
    inline class Character(val impl: Char): Token()
    it would make one of my tokenizers run a whole lot faster
    s
    a
    • 3
    • 20
  • d

    dumptruckman

    02/07/2019, 9:40 PM
    trying to do
    () -> Unit
    but it is expecting a return value
    a
    • 2
    • 1
  • d

    dumptruckman

    02/07/2019, 10:09 PM
    How can I user an optional generic type?
    s
    • 2
    • 1
  • u

    ursus

    02/08/2019, 3:54 AM
    is anyone using the Result monad in production?
    k
    g
    g
    • 4
    • 17
  • a

    antonis

    02/08/2019, 8:55 AM
    Hello, I was wondering if there is a way to pass an operator (like >, =< etc) as a parameter to a function. Since e.g. comparison operators are translated to a.compareTo(b) function calls how is it possible to pass the actual operator in a function like: fun someFunction(operator: Int.(Int) -> Boolean)
    d
    • 2
    • 4
  • t

    thana

    02/08/2019, 8:57 AM
    What is the rationale behind the decision not to provide a "package private" visibilty? (i think even better would be something like a "friend" visibility)
    m
    h
    +3
    • 6
    • 12
  • k

    karelpeeters

    02/08/2019, 10:29 AM
    class Env {
        fun sub() = SubEnv(this)
    }
    
    class SubEnv(val parent: Env)
    Is there a nice way to make
    sub()
    the only possible way to construct a
    SubEnv
    instance? Making the constructor of
    SubEnv
    private
    isn't allowed. Making
    SubEnv
    an inner class doesn't help either, you're still not allowed to make the constructor private.
    s
    • 2
    • 2
  • s

    svenjacobs

    02/08/2019, 11:19 AM
    Does Kotlin provide some kind of annotation for public functions that are however considered "internal" API and should not be used? As a library developer I provide a public inline function. However this func references another "internal" utility function. The utility function should actually not be used outside of the library but since the inline function is public I cannot declare this utility function as
    internal
    . So I just want to warn users if they are accidentally using the internal function.
    d
    • 2
    • 1
  • d

    dumptruckman

    02/08/2019, 4:42 PM
    grrr, I will always be upset about the decision to remove package-private and stopping protected from being visible in package scope
    👍 1
    h
    • 2
    • 3
  • h

    HaSH

    02/08/2019, 7:01 PM
    The if would be here
    d
    k
    • 3
    • 60
  • k

    kevinmost

    02/08/2019, 7:43 PM
    internal
    is
    public
    in Java, but they mangle the name in bytecode so it's not that bad. Nobody will look at that method name and want to call it.
    r
    d
    +2
    • 5
    • 11
  • d

    dumptruckman

    02/08/2019, 8:16 PM
    Is there a more idiomatic way to write this?
    val contentBodyP2MessageKey = template.contentBodyP2MessageKey
            val contentBodyP2MessageArgs = template.contentBodyP2MessageArgs
            if (contentBodyP2MessageKey != null && contentBodyP2MessageArgs != null) {
                val contentBodyP2 =
                    messageSource.getMessage(contentBodyP2MessageKey, contentBodyP2MessageArgs(environment), locale!!)
                context.setVariable("contentBodyP2", contentBodyP2)
            }
    a
    • 2
    • 2
  • t

    tianhao

    02/09/2019, 12:14 AM
    Does Kotlin support catch multiple exceptions similar to Java now?
    🇳🇴 2
    k
    g
    g
    • 4
    • 6
  • t

    tianhao

    02/09/2019, 2:24 AM
    How can I check that two lambdas are the same operations? For example, the argument of a function is a lambda:
    op: (Double, Double) -> Double
    and the parameters I will pass could be:
    { op1, op2 -> op1 + op2 }
    ,
    { op1, op2 -> op1 - op2 }
    or
    { op1, op2 -> op1 / op2 }
    . So how can I check
    op
    is equals
    \
    operation I passed in inside of the method?
    a
    • 2
    • 1
  • h

    Hexa

    02/09/2019, 10:21 AM
    We still use Java in our codebase but we are slowly migrating to Kotlin
    a
    • 2
    • 1
  • j

    Jakub Aniola

    02/09/2019, 6:40 PM
    What virtual machine is used by IntelliJ when I compile Kotlin code? Is it connected with configured JRE/JDK 1.8 etc? Is it Oracle HotSpot?
    e
    n
    i
    • 4
    • 3
  • g

    GarouDan

    02/10/2019, 12:14 AM
    I don’t know where I can file an issue about this but I had verified that there is an
    error in the "Kotlin (Mobile Android/iOS)" template
    in IntelliJ to create a new project. The android
    buid.gradle
    is not correct configured since it is prepared to copy a
    app.framework
    but the build process is generating a
    main.framework
    . Also, the references in the
    iosApp
    , specially in the
    project.pbxproj
    are wrong, pointing the the
    app.framework
    . I tried several variations trying to change the
    main.framework
    to the
    app.framework
    but it wasn’t working. What worked was the opposite, change the references from
    app.framework
    to
    main.framework
    . I think this worked because the module exported is
    main
    but not
    app
    . So I needed to fix the imports in the project too. Ufa! I had a hard time trying to put this to work, since this was my first project using android and ios.
    c
    • 2
    • 2
  • t

    tipsy

    02/10/2019, 9:18 AM
    i heard there was a compiler option to enable SAM conversion, can anyone point me to the docs for that?
    n
    d
    • 3
    • 16
  • j

    Jakub Aniola

    02/10/2019, 2:43 PM
    Can someone recommend me place where I can read more about Kotlin JVM compiler? Is it the same JIT compiler which is a part of JRE? I assume not because I can check out compiler codebase on Github 😛
    n
    • 2
    • 1
  • g

    GarouDan

    02/10/2019, 2:46 PM
    I’m working on a project in IntelliJ but it keeps doing background operations when I’m editing a build.gradle.kts file. Is is possible to disable this behavior so we could hit this background process only after we save the file?
    l
    m
    • 3
    • 3
  • d

    Dalinar

    02/10/2019, 3:16 PM
    what is the kotlin way to use
    .use
    if it is used on the next line? should it be indented or should it be flush with the object on the line above?
    d
    c
    k
    • 4
    • 7
Powered by Linen
Title
d

Dalinar

02/10/2019, 3:16 PM
what is the kotlin way to use
.use
if it is used on the next line? should it be indented or should it be flush with the object on the line above?
d

Dominaezzz

02/10/2019, 3:30 PM
Next line if the line is too long. Up to developer to define too long.
d

Dalinar

02/10/2019, 3:31 PM
yeah, line is very long, multiple lines actually for this code - but the question is - if it is on the next line should it be
.use {
or
(tab).use {
(indented)? .. it seems to look better non-indented to me
d

Dominaezzz

02/10/2019, 3:34 PM
Ah I misread.
I think it should be flush.
c

Czar

02/10/2019, 3:36 PM
someObject
    .use {
        //logic
    }
k

karelpeeters

02/10/2019, 5:45 PM
Just look at what Idea autoformats it to?
d

Dalinar

02/11/2019, 5:28 PM
sure I saw that already, but I wasn't sure if it specifically knew it was a .use or just formatting it according to some general rule (more likely)
View count: 1