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

    Ruckus

    05/11/2018, 7:22 PM
    You have a formatting error. You need to move the
    {
    to the same line as the
    let
    s
    k
    • 3
    • 11
  • r

    raulraja

    05/14/2018, 8:04 PM
    @benleggiero I like it all but I think the use of
    as
    is missleading since it's already associated with casting. I think what you have here is an explicit type ascription and
    :
    would be more appropiate since that is already used for type ascription in functions, local variables etc. It's also how it's represented in other languages: https://stackoverflow.com/questions/36389974/what-is-type-ascription https://stackoverflow.com/questions/2087250/what-is-the-purpose-of-type-ascriptions-in-scala
    takesAmbiguousType([1, 2, 3] : Set<Int>) // OK
    takesAmbiguousType([1, 2, 3] : Array<Int>) // OK
    👍 3
    b
    • 2
    • 1
  • i

    ilya.gorbunov

    05/14/2018, 8:38 PM
    @raulraja Type ascription was removed not long before Kotlin 1.0 presumably to free that syntax for map literals 😉
    😮 1
    b
    a
    • 3
    • 3
  • o

    orangy

    05/14/2018, 9:10 PM
    I mean not the syntax itself, but decent samples. E.g. I have a data class
    Configuration(val host: String, val port: Int, val filters: List<Filter>)
    and I want to build a
    Map<String, List<Configuration>>
    . How would it look like?
    👍🏼 2
    i
    b
    • 3
    • 6
  • a

    Aregev2

    05/15/2018, 5:06 PM
    Why named parameters (i.e testFun(message="txt") accepted only in kotlin classes and not in any class? Is there a plan to implement it for all classes? ( if it's possible)
    g
    • 2
    • 1
  • b

    benleggiero

    05/15/2018, 10:17 PM
    This gets back to the discussion about having separate parameter labels vs names
    k
    r
    +3
    • 6
    • 36
  • k

    karelpeeters

    05/16/2018, 8:27 AM
    @mmaillot That already exists, right?
    m
    • 2
    • 1
  • t

    tschuchort

    05/16/2018, 10:36 AM
    not sure if this is even the right channel, but how soon can we expect local function declarations in inline functions?
    g
    k
    r
    • 4
    • 11
  • b

    bbade_

    05/17/2018, 10:02 PM
    When I write Rx i often make two properties. A private one with a specific interface, then a public one with a more general interface.
    private val _events: ReplaySubject<Thing>
    val events: Observable<Thing>
        get = _events
    Has there been any consideration about adding syntax like this as a shorthand?
    private val events: ReplaySubject<Thing>
        public get(): Observable
    💯 9
    ➕ 5
    l
    k
    • 3
    • 4
  • e

    elect

    05/18/2018, 7:40 AM
    I'd really love to have
    return
    in
    init
    l
    b
    a
    • 4
    • 23
  • a

    amorenew

    05/21/2018, 6:33 AM
    why Kotlin not support varA = varB = varC or varA,varB = varC
    g
    • 2
    • 3
  • b

    benleggiero

    05/22/2018, 1:08 AM
    So… overloads that conflict because only the return types differ. I’m not sure how deep into bytecode the erasure goes, but I would like to propose we allow this. Perhaps the first iteration might have to mangle the JVM names to make this happen, in which case it should come with an
    @
    annotation that says “Yes, I know this will make things weird for other JVM languages but I really want this”. Hopefully it’s possible without name mangling, though. The reason I propose this feature is because it would be essential for the Collection Literals KEEP as it’s currently written. https://github.com/Kotlin/KEEP/pull/112#issuecomment-390830008
    r
    r
    • 3
    • 9
  • w

    wcaokaze

    05/24/2018, 3:26 PM
    Hi. I'm not good at English but I made up a note about my proposal. Please read it https://github.com/wcaokaze/KEEP/blob/root-packages-and-package-unit-imports/proposals/root-packages-and-package-unit-imports.md
    b
    g
    • 3
    • 37
  • e

    efemoney

    05/25/2018, 8:58 AM
    With Dagger you can add qualifier (annotations) to generic classes like
    @Named("coins") Safe coinSafe;
    @Named("jewelry") Safe jewelrySafe;
    In a large codebase people might forget to add the right annotation or in the case of
    Named
    , the correct value. Being able to create a
    typealias
    like below would be really helpful.
    typealias CoinSafe = @Named("coins") Safe
    typealias JewelrySafe = @Named("jewelry") Safe
    
    // and usage becomes
    CoinSafe coinSafe;
    JewelrySafe jewelrySafe;
    I’m also quite skeptical though, because
    typealias
    (right now) implies interchangeability and for special cases/mistakes with this feature, interchanging types might introduce bugs.
    ➖ 1
    ➕ 2
    b
    g
    • 3
    • 5
  • p

    Pere Casafont

    05/25/2018, 11:21 AM
    by the way, what would you think about an
    implement
    keyword to be used instead of
    override
    when what you're "overriding" are actually interface or abstract methods?
    👍🏼 2
    👎 5
    s
    r
    +3
    • 6
    • 25
  • p

    paulblessing

    05/31/2018, 4:04 PM
    Person(
        name = run {
          // some complicated things
          "Nathan"
        },
        
        age = run {
          // some complicated things
          17
        }
    )
    🤔 2
    b
    k
    • 3
    • 2
  • z

    Zac Sweers

    05/31/2018, 6:49 PM
    has there ever been a proposal around deferring to default values for named params? Use case being that there's cases where you may or may not have a value for a named param, but don't want to write out every possible permutation for function/constructor invocations to allow default values to run
    data class Foo(val bar: String, val baz: String = "baz")
    
    // somewhere later
    val bazValue = getBazValue() ?: Unset
    Foo(
      bar = "bar",
      baz = bazValue
    )
    Unset
    (name could be something better) could be a marker to indicate that you want to defer to the default value. Similar to
    Unset
    . Then you could denote that a value is undefined and basically pretend the argument was never set
    ➕ 3
    b
    n
    • 3
    • 3
  • w

    waqas

    06/11/2018, 2:26 PM
    I ended up using Lazy<String> to solve my problem, but I think @diesieben07 is asking for something else 🤔
    b
    • 2
    • 1
  • d

    diesieben07

    06/11/2018, 2:28 PM
    Yeah. I would like
    "Hello $name"
    to compile to something like a
    StringTemplate
    object (if needed, it should also still be assignable to
    String
    obviously). More hand-wavy API:
    interface StringTemplate {
        val placeholders: List<String>
        fun getValue(placeholder: String): Any?
        fun toString(mapper: (@ParameterName("name") String, @ParameterName("value") Any?) -> Any?): String
    }
    k
    • 2
    • 4
  • n

    nwh

    06/18/2018, 1:52 AM
    Would it be feasible to be able to implement entire types via extensions? For example:
    interface Flippable<T> {
    	fun flip(): T
    }
    
    extend String as Flippable<String> {
    	// Implements all of the Flippable properties/methods missing from the base class
    	fun flip(): String {
    		...
    	}
    }
    Then you could treat a
    String
    as an instance of
    Flippable
    ➕ 1
    w
    b
    +6
    • 9
    • 60
  • z

    Zac Sweers

    06/19/2018, 7:32 AM
    unrelated
    if (title == null) title = tmdbEpisode.name
    I wish I could do
    title ?= thing
    . Like Ruby’s
    ||=
    where it assigns only if not assigned yet. That could possibly mesh nicely with what I was raising here too: https://kotlinlang.slack.com/archives/C0B9K7EP2/p1527792590000151
    v
    i
    • 3
    • 5
  • n

    nwh

    06/19/2018, 10:42 PM
    Seems to me it would be good idiomatically if
    catch
    could receive errors as a parameter, like this:
    try { ... } catch { it.printStackTrace() }
    I assume this would be a breaking change, but just allowing it to receive a parameter wouldn't be (no implied
    it
    ):
    try { ... } catch { err -> ... }
    If both of these are breaking changes, maybe the syntax could be changed to
    handle
    instead of
    catch
    , and the try statement would have to have one or the other. The current syntax of
    catch
    drives me nuts.
    🤔 1
    r
    d
    +3
    • 6
    • 9
  • l

    littlelightcz

    07/04/2018, 5:19 PM
    I think it would be nice to add some kind of .random() or .randomOrNull() extension functions to the collections in the Kotlin standard library (see https://stackoverflow.com/a/47850157/1277145 ). I found myself needing this feature 2 times already and I always had to do a custom implementation for that 🙂. Thanks in advance!
    i
    • 2
    • 2
  • d

    dodalovic

    07/09/2018, 3:55 PM
    I was wondering if we could have functions like
    topLevelFun() = Unit
    
    class Foo {
        bar() {
            //
        }
        baz() = println("baz")
    }
    ➖ 5
    r
    g
    +2
    • 5
    • 10
  • d

    dodalovic

    07/09/2018, 4:33 PM
    Btw - does anybody know why for multi-line strings we use """ABC""" instead of let's say backticks
    g
    • 2
    • 2
  • i

    ilya.gorbunov

    07/13/2018, 8:08 PM
    📣 The proposal for unsigned integer types: https://github.com/Kotlin/KEEP/issues/135
    😆 2
    🤘 2
    🎉 9
    👍 10
    ➕ 1
    k
    a
    +2
    • 5
    • 28
  • a

    Aregev2

    07/13/2018, 8:34 PM
    What about UFloat and UDouble?
    i
    b
    • 3
    • 6
  • b

    benleggiero

    07/15/2018, 9:03 PM
    I would like to see number types have more interfaces that they conform to, to let me reason about them better. For instance, right now I have to have to make separate, specialized versions of classes for each individual number type, like
    Int64Size
    vs `Int8Size`: https://github.com/BlueHuskyStudios/Blue-Base/commit/5baf26fb495b29bd9ad4a7b1099d76c9f0c1c163 Just about all the code between these classes is identical, but solely because I can only say either “Use a `Long`” or “Use any implementation of `Number`“, I have to slowly go through every native number type and make separate implementations for these. If I could just specify “This is a
    Size
    implementation based on a native integer”, I could write it once and let generics fill in the blanks. Swift did this with a set of 9 interfaces, and it makes it super easy to let the compiler reason about what I’m getting at: https://developer.apple.com/documentation/swift/swift_standard_library/numbers_and_basic_values/numeric_protocols https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.md
    👍 1
    k
    • 2
    • 5
  • d

    Dominaezzz

    07/16/2018, 11:09 AM
    Destructors or multi-platform `Closeable`/`Disposable` interface. Just to provide some standard way of specifying resources to be released by the user and not necessarily the runtime. A class/object with a destructor would pretty much behave like a class that implements
    AutoCloseable
    , which I think should be the JVM implementation of it.
    a
    s
    d
    • 4
    • 12
  • d

    dsavvinov

    07/16/2018, 3:28 PM
    📣 The proposal for Kotlin Contracts: https://github.com/Kotlin/KEEP/issues/139 As usual, your feedback is very welcome! 🙂
    🎉 3
    👍 13
    🙌🏼 2
    j
    v
    • 3
    • 2
Powered by Linen
Title
d

dsavvinov

07/16/2018, 3:28 PM
📣 The proposal for Kotlin Contracts: https://github.com/Kotlin/KEEP/issues/139 As usual, your feedback is very welcome! 🙂
🎉 3
👍 13
🙌🏼 2
j

jdemeulenaere

07/16/2018, 7:54 PM
This is awesome !
v

voddan

07/17/2018, 12:28 PM
I propose we call them "definitely-not-macros"
😂 1
View count: 2