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
language-proposals
  • a

    aarjav

    11/28/2018, 5:48 PM
    thoughts on having argument labels like in swift? https://docs.swift.org/swift-book/LanguageGuide/Functions.html#ID166 I can see it being helpful in dsl design but I haven't used them.
    i
    r
    g
    • 4
    • 13
  • i

    igor.wojda

    12/06/2018, 1:45 PM
    Any particular reason why
    iterator
    in
    Iterable
    is a method, not a property?
    b
    • 2
    • 1
  • r

    rrader

    12/06/2018, 4:07 PM
    Is there a proposal about union type, like in Ceylon, if so, can you please send the link?
    g
    • 2
    • 2
  • f

    fcosta

    12/06/2018, 5:59 PM
    Heys guys, are there any plans to have a
    pattern matching
    feature like other languages have like Elixir?
    o
    • 2
    • 2
  • t

    tevjef

    12/10/2018, 7:41 PM
    I'm curious why this works
    fun a(): Unit
    ==
    fun a()
    but this doesn't:
    fun b(G: Unit)
    !=
    fun b()
    i
    n
    • 3
    • 2
  • s

    Slackbot

    12/11/2018, 8:15 AM
    This message was deleted.
    g
    • 2
    • 1
  • j

    josephivie

    12/13/2018, 2:44 AM
    What about making frozen-ness a part of type, much like nullability is? Maybe a
    #
    at the end to indicate that you expect a mutable thing rather than a frozen thing. I haven’t thought this all the way through yet. There might be some big problems with that. I just see immutability issues being a huge problem for Kotlin Native in the future unless we have some language features to prevent some common issues.
    👍🏽 1
    👍🏼 3
    d
    • 2
    • 1
  • x

    xenoterracide

    12/27/2018, 7:23 PM
    suggestion: allow trailing commas to be optional (same way ; can be noise punctuation), the following code should compile, and behave the same way as if the last comma were not present
    val modules = listOf(
        "ph-db-migration",
        "ph-emr-entity",
        "ph-emr-event-type",
        "ph-events",
        "redox",
    )
    you probably wouldn’t write this like this, but it makes the last comma more obvious
    val modules = listOf( "ph-db-migration", "ph-emr-entity", "ph-emr-event-type", "ph-events", "redox",)
    would compile to the same thing as
    val modules = listOf( "ph-db-migration", "ph-emr-entity", "ph-emr-event-type", "ph-events", "redox")
    ➕ 2
    💯 2
    👍 7
    k
    o
    +2
    • 5
    • 15
  • x

    xenoterracide

    12/30/2018, 6:01 AM
    suggestion: full support for traits. Syntactically I feel like kotlin already does with interfaces, but interfaces cannot have state currently, a trait on the other hand can store state but can't be instantiated (outside of anonymous class... ) itself. I actually thought kotlin had this, because you can put a val in the interface, however I didn't realize you'd then have to override that in the composing class. Basically I want support for Perl 6 Style role's except statically typed.
    👍 1
    k
    r
    +3
    • 6
    • 43
  • x

    xenoterracide

    12/30/2018, 6:03 AM
    suggestion: support private/protected keywords on interfaces protected would mean accessible by anything that extends/implements the interface via this.
    👍 2
    d
    g
    a
    • 4
    • 10
  • n

    natpryce

    01/02/2019, 10:45 AM
    Suggestion: toString of an object declared with an
    object
    expression should return the object’s name without the ‘@<id>’ suffix.
    👍 1
    d
    o
    • 3
    • 3
  • b

    breandan

    01/05/2019, 3:57 AM
    Re-posting here for visibility:
    Kotlin should automatically choose lambda expressions with a single argument over multiple arguments for the implicit case. You should not need to specify an explicit lambda signature in order to use
    it
    when competing overloads all have higher arity.
    https://github.com/kotlintest/kotlintest/pull/506#issuecomment-451624300
    a
    i
    • 3
    • 5
  • j

    jw

    01/07/2019, 7:33 PM
    Has there been any discussion around inline classes and having them conform to a contract similar to enums? For example, it'd be nice to be able to generify over the ability to wrap/unwrap. With enums I can bound a generic on
    : Enum<T>
    which (combined with
    inline
    ) lets me do
    T -> String
    and
    String -> T
    conversion. It would be nice to achieve similar
    T -> V
    and
    V -> T
    conversions with an inline type (where
    V
    is the property type) in a generic way. Right now I'm using a factory where you have to pass
    ::Foo
    and
    Foo::property
    as arguments which leaves a lot to be desired.
    👍 3
    k
    o
    r
    • 4
    • 26
  • m

    Marc Knaup

    01/09/2019, 12:54 PM
    I have it sooo often that I have to unwrap inline classes, do some basic operation and then wrap it again. That’s quite annoying and you can change the result to a different inline class without even noticing.
    m
    • 2
    • 4
  • m

    Marc Knaup

    01/09/2019, 12:57 PM
    You’d still have to type safety to not assign a
    Username
    to an
    EmailAddress
    for example.
    a
    • 2
    • 2
  • d

    diesieben07

    01/09/2019, 1:21 PM
    Your "transparent inline class" is called
    typealias
    😉
    ➕ 4
    m
    c
    r
    • 4
    • 12
  • o

    Olekss

    01/09/2019, 8:45 PM
    Hi. Very quick question. Is there any KEEP or proposal to introduce something like clojure keywords in kotlin?
    r
    • 2
    • 2
  • o

    Olekss

    01/09/2019, 9:11 PM
    @Roman, my Person and your Person will not compose, even if both have the same exact name and date params as their constructor params
    e
    a
    +2
    • 5
    • 16
  • o

    Olekss

    01/09/2019, 9:12 PM
    Jake, well even now I can write as my example, define enums and strings, and use them as keywords... but keyword concept is a bit more - it defines and uses at the same time and it evaluates to itself, or is a function
    e
    i
    • 3
    • 4
  • k

    kioba

    01/11/2019, 4:45 PM
    In Scala you can destruct a type with pattern matching. It comes quite handy when we have to work with containers. An example to it is:
    def listToString(list: List[String]): String = list match {
        case s :: rest => s + " " + listToString(rest)
        case Nil => ""
    }
    would it make sense to add a similar pattern matching for the destructuring declaration? the example above could be replaced with `fold`/`reduce` and mixing it with
    windowed
    but if the list length is zero we would get an exception
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    with pattern matching this could be automatically run to the
    case Nil => ""
    . The compiler also could check for unsatisfied cases just like it does right now when we match agains for enum or sealed class types
    d
    e
    • 3
    • 20
  • m

    Marc Knaup

    01/12/2019, 10:25 AM
    Random idea: When removing the
    package
    directive from all Kotlin files of a project then a compiler option allows specifying the same package name for all Kotlin files instead of using the root package. So I can stop repeating myself.
    d
    • 2
    • 7
  • x

    xenoterracide

    01/14/2019, 11:07 PM
    hmm... idea, keyword
    test
    on a class makes the class internal, and so that you can't directly call any constructors. on a method it would make it internal (is this a thing for a method?). Motivation, avoid ID10T errors involving trying to new up the test in your code, vs trying to new up the class under test 😕 also the internal keyword is long and test reads better.
    😱 2
    r
    • 2
    • 3
  • r

    Ruckus

    01/17/2019, 6:07 PM
    Proposal: Allow a training
    =
    on any var infix function that returns the receiver's type (or compatible):
    // Current
    var superAwesomeNumber = 5
    superAwesomeNumber = superAwesomeNumber shl 3
    
    // New
    var superAwesomeNumber = 5
    superAwesomeNumber shl= 3
    It would be nice for long chains of bitwise operators, but it could also be nice for any infix function. It is especially appealing when you use very descriptive names.
    👍 4
    👎 3
    o
    h
    +2
    • 5
    • 13
  • c

    cedric

    01/18/2019, 5:32 PM
    Rust’s new
    dbg!()
    macro looks pretty useful, I was wondering if it would be possible to replicate it in Kotlin. This would require being able to capture the text form of the expression. https://blog.rust-lang.org/2019/01/17/Rust-1.32.0.html
    ➕ 10
    r
    r
    • 3
    • 4
  • c

    cbruegg

    01/20/2019, 12:53 PM
    It's also very expensive.
    ➕ 1
    h
    • 2
    • 2
  • e

    elect

    01/21/2019, 9:54 AM
    what about
    @JvmOverloads
    on interface methods?
    l
    p
    • 3
    • 9
  • j

    josephivie

    01/24/2019, 5:33 PM
    Would extension fields be feasible? As in actual storage and retrieval of a value? On the JVM it could use some form of WeakHashMap backing it. Not the default implementation, as it won't clean up after itself properly, but maybe something using PhantomReference. For JS it could actually just use a property I dunno about Native. It could be useful in cases where you want to "tag" an object with some data, but only want that data around as long as the object.
    👍 1
    x
    h
    +3
    • 6
    • 30
  • j

    josephivie

    01/28/2019, 9:15 PM
    I know this is probably specific to my use case only, but it would be mighty nice if I could instantiate an annotation class in common code. I’ve written an external reflection plugin and library, and have to use an awkward wrapper around annotation information because I can’t just instantiate the annotation class itself.
    g
    • 2
    • 6
  • s

    Slackbot

    01/28/2019, 10:18 PM
    This message was deleted.
    j
    x
    • 3
    • 3
  • m

    Matej Kormuth

    02/03/2019, 12:06 AM
    It would be nice to have
    it
    or similar variable in
    else
    clause of
    when
    control structure.
    when (a()) {
        1 -> b()
        2 -> c()
        else -> d(it)
    }
    ➕ 1
    r
    m
    +2
    • 5
    • 4
Powered by Linen
Title
m

Matej Kormuth

02/03/2019, 12:06 AM
It would be nice to have
it
or similar variable in
else
clause of
when
control structure.
when (a()) {
    1 -> b()
    2 -> c()
    else -> d(it)
}
➕ 1
r

Ruckus

02/03/2019, 12:19 AM
You can assign in the statement:
when (val res = a()) {
    ...
    else -> d(res)
}
The advantage of this as opposed to assigning a val before the when is that
res
is confined to the scope of the when.
🤩 1
👍 1
m

Marc Knaup

02/03/2019, 5:00 AM
I guess adding an implicit
it
would also break existing code where
when
together with
it
is used in a lambda. btw it's not just a problem with
else
but also the other branches. You don't have the value in the right type there unless you use the preferred approach Ruckus has mentioned.
x

xenoterracide

02/04/2019, 4:24 PM
death to syntax, when should be a method call! so should if
b

benleggiero

02/05/2019, 2:28 AM
@Ruckus!! I had no idea of that syntax!! Thank you!!
View count: 2