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

    Xavier F. Gouchet

    12/06/2019, 12:17 PM
    Hey, I have a list of Strings, and a list of lambdas that convert String to String. Is there a way to apply all lambdas sequentially to all the Strings in the list ? eg:
    val transforms = listOf<(String) -> String>(
        { it.toLowerCase() },
        { it.split(",").first() }
    )
    val data = listOf("foo, 42", "BAR, 33")
    
    val result = data.mapAll(transforms) // result has ["foo", "bar"]
    k
    a
    • 3
    • 5
  • r

    ribesg

    12/06/2019, 1:56 PM
    I don’t know who to report this to, but on the new mobile MP page, in point 6 example code, a variable is named
    allPositions
    instead of
    allProducts
    I think https://www.jetbrains.com/lp/mobilecrossplatform/
    e
    • 2
    • 3
  • a

    arekolek

    12/06/2019, 3:30 PM
    Route
    is not a
    Router
    .handler()
    doesn’t return a
    Router
    probably even
    .route()
    doesn’t return it already
    a
    • 2
    • 1
  • l

    LastExceed

    12/06/2019, 9:19 PM
    I have a question about language design: why does kotlin use curly braces ? jetbrains has shown us that they put great thought into what actually matters and is logically the best choice even when it clearly goes against what people are used to and would instinctively support (most prominent example of that would be "public by default" which is disliked by almost anyone who's new to kotlin). The fact that we indent all our code even though the language doesnt require it shows that we (the humans) read code via indent and not via braces. so why not remove them altogether and make scoping indentation based (like python or haskell) to reduce verbosity? I know that many people instinctively dislike this idea, and I have ask as many people that prefer braces as possible trying to understand their reasoning, but I have yet to find a single valid point that speaks for curly braces over indentation based syntax. i seems to simply come from habit. to me curly braces are like semicolons, they used to be absolutely mandatory for the compiler to work but with modern technology have since become obsolete and are only kept around for legacy reasons. but maybe i am missing something, maybe there is a case where braces provide some sort of advantage that havent thought of yet? to be clear i dont suggest kotlin to change in that regard, thats clearly impossible at this point even if we wanted to. I'm just really interested in language design and how and and why certain decisions are made the way they are.
    💡 3
    c
    m
    +2
    • 5
    • 22
  • b

    bbaldino

    12/06/2019, 9:44 PM
    is it not possible to use a reference to a field in a companion object without using
    .Companion
    ?
    class Foo {
        companion object {
            val bar: Int = 42
        }
    }
    // Works
    val member2 = Foo.Companion::bar
    // Doesn't work: unresolved reference
    val member = Foo::bar
    k
    m
    e
    • 4
    • 12
  • g

    Gerard Klijs

    12/07/2019, 2:11 PM
    Looking how to combine predicates. The problem is the input is all nullable, and only when there is an input a predicate should be used. Any way to improve this, it's working correctly now.
    private fun filterFunction(direction: DType?, iban: String?, minAmount: Int?,
                               maxAmount: Int?, descrIncluded: String?): Predicate<Transaction> {
        val predicates: MutableList<Predicate<Transaction>> = ArrayList()
        direction?.let { predicates.add(Predicate { t: Transaction -> t.direction == direction }) }
        iban?.let { predicates.add(Predicate { t: Transaction -> t.iban.equals(iban) }) }
        minAmount?.let { predicates.add(Predicate { t: Transaction -> t.amount >= minAmount }) }
        maxAmount?.let { predicates.add(Predicate { t: Transaction -> t.amount <= maxAmount }) }
        descrIncluded?.let { predicates.add(Predicate { t: Transaction -> t.descr.contains(descrIncluded, true) }) }
        return Predicate { transaction: Transaction ->
            predicates.all { predicate: Predicate<Transaction> -> predicate.test(transaction) }
        }
    }
    e
    • 2
    • 3
  • q

    Quy D X Nguyen

    12/08/2019, 6:35 AM
    Is it possible to access static members on reified generics?
    p
    k
    s
    • 4
    • 4
  • d

    dmcg

    12/08/2019, 10:11 AM
    Where would be a good channel to discuss contracts?
    k
    • 2
    • 1
  • a

    Ashutosh Panda

    12/08/2019, 1:32 PM
    val fishnet="Net"to"Catch fish"
    
    val(tool,use)=fishnet
    println("$tool and $use")
    k
    • 2
    • 4
  • a

    Ashutosh Panda

    12/08/2019, 1:47 PM
    This is the error
    k
    • 2
    • 16
  • m

    Matthew

    12/08/2019, 1:54 PM
    Hello guys, I have a question about what would be the best workaround for the method I posted https://youtrack.jetbrains.com/issue/KT-35301 here?
    k
    • 2
    • 4
  • t

    Tim McCormack

    12/08/2019, 2:28 PM
    It's not terrible that I have to use SAM syntax, and most of the time I can take a Kotlin function instead; this is just me being curious about why the compiler is preventing the trailing lambda call in one place vs. another.
    k
    • 2
    • 19
  • a

    asad.awadia

    12/08/2019, 3:50 PM
    Wonder why kotlinconf was same week as reinvent - wouldn’t the attendance be higher if it weren’t?
    r
    g
    • 3
    • 3
  • c

    Czar

    12/08/2019, 4:56 PM
    so is there a consensus on:
    if(x != null) y = x
    vs
    x?.let { y = x }
    vs custom
    ifNotNull(x) { y = it }
    vs
    y = x ?: y
    ? (I know, that the last one is not 100% equivalent to others as in case of property it invokes setter in any case)
    1️⃣ 1
    a
    k
    +3
    • 6
    • 12
  • r

    russhwolf

    12/08/2019, 6:39 PM
    When graduating an experimental API (https://kotlinlang.org/docs/reference/experimental.html#graduation-of-experimental-api), does the deprecation level matter? ie would it cause issues for consumers (other than requiring them to update immediately) if the level was set to
    HIDDEN
    instead of the default
    WARNING
    ? (I’d love to ask this in a more specific channel, but not sure what a good one would be)
    k
    • 2
    • 2
  • r

    Robert

    12/08/2019, 10:06 PM
    Is there any multiplatform library for networking? Sockets maybe? I like to make a connection to DNS
    m
    • 2
    • 2
  • a

    Ashutosh Panda

    12/09/2019, 6:33 AM
    ok if I remove the second line I am getting the value but why is it showing error
    c
    • 2
    • 1
  • m

    Marcin Wisniowski

    12/09/2019, 7:11 AM
    I'm unable to add two
    BigInteger
    s, both when I use
    +
    and
    plus()
    . I get a compiler error about overload ambiguity: <https://ss.nohus.eu/14331/03576c27> How to fix this error? This does not compile:
    fun main() {
        BigInteger.ONE + BigInteger.ONE
    }
    🤔 3
    m
    b
    t
    • 4
    • 8
  • r

    Robert

    12/09/2019, 7:54 AM
    Where should I ask questions about generating shared c libraries? I would like how to publish types from dependencies. In this case ionspin's BigInteger class. It is defined as a struct
    libpaycoin_kref_com_ionspin_kotlin_bignum_integer_BigInteger
    but it's methods aren't published. I tried typealiassing it, but it ignores this.
    a
    • 2
    • 3
  • f

    fradiati

    12/09/2019, 8:23 AM
    I have a List in my java file. java.util.List, and i have a function in my kotlin class which add theese items to a mutableList. I get UnsupportedOperationException and i can"t solve it with stackoverFlow posts. What can I do?
    d
    • 2
    • 18
  • c

    coletz

    12/09/2019, 8:50 AM
    Hi guys, not sure if this is the best channel to ask but I'll try anyway. Is there anything like https://github.com/google/google-java-format for kotlin?
    j
    m
    • 3
    • 3
  • d

    dmcg

    12/09/2019, 9:10 AM
    Sorry, very nitty-gritty Kotlin contracts question - thought it best to ask on SO https://stackoverflow.com/q/59245615/97777
    s
    s
    • 3
    • 7
  • w

    Wesley Acheson

    12/09/2019, 11:48 AM
    Sorry new to all of this but is there a way to wrap and extend a data class. Say if I had a data class
    Summary
    and I wanted to create a data class
    SummaryCalculation
    that had all the fields of Summary but had new field also.
    data class Summary(val aProperty:String, val items:List<BillableItem>)
    
    //This I don't know
    data class BillingSummary(initialSummary:Summary, totalItemsBilled:Long):Summary
    It doesn't actually need to share an equals/hashcode, just expose the same api. I'm more or less trying to create an envelope that holds addition properties. that can be created from the initial object.
    d
    m
    • 3
    • 5
  • a

    Ashutosh Panda

    12/09/2019, 12:11 PM
    Hi can anyone please explain me what is companion object and how it is related to static members and static methods( I know C++)
    d
    • 2
    • 16
  • s

    steenooo

    12/09/2019, 1:27 PM
    hey uhm, Im writing a kotlin plugin loader for For minecraft development (spigot). Some features require alot of annoying boilerplate. Since I control the classloader used to load it, would it be advicable to add a feature to generate this boilerplate with ASM when loading the class? (They already modify the bytecode a little bit). Fx their event system requires you to provide a static instance of an object, and override a method returning this instance. Its the same few lines for every class extending class. This makes the code in kotlin very ugly
    m
    b
    g
    • 4
    • 9
  • l

    LastExceed

    12/09/2019, 2:32 PM
    im getting a compile error that i dont understand:

    https://i.imgur.com/6kNkSRr.png▾

    it says "unresolved reference" even though in the editor it seems to be recognized just fine, it shows up in autocomplete and i can navigate to the implementation just fine. whats going on here?
    s
    a
    +2
    • 5
    • 63
  • p

    poohbar

    12/09/2019, 6:17 PM
    Why does the smart-casting not work here? And how would you solve it?
    fun main() {
        var value: Any? = "hello"
    
        if (value != null) {
            for (i in 1..10) {
                value = nonNullFoo(value) // smart casting fails
            }
        }
    }
    
    fun nonNullFoo(obj: Any): Any {
        return "World"
    }
    l
    n
    +2
    • 5
    • 17
  • t

    thymecypher

    12/09/2019, 8:15 PM
    Is there a JetBrains slack? Or just the Discord?
    m
    h
    +2
    • 5
    • 48
  • s

    steenooo

    12/09/2019, 8:23 PM
    Is there a kotlin/jetbrains discord?
    u
    • 2
    • 3
  • p

    Pacane

    12/09/2019, 9:43 PM
    I tried
    @NotNull
    from
    org.jetbrains.annotations
    but the converter doesn't care about those apparently
    g
    a
    • 3
    • 3
Powered by Linen
Title
p

Pacane

12/09/2019, 9:43 PM
I tried
@NotNull
from
org.jetbrains.annotations
but the converter doesn't care about those apparently
g

gildor

12/09/2019, 11:35 PM
Yes, it's correct, it should work. If it doesn't, please fill a bug with example of code
I remember similar issue with new J2K converter
a

Arian Stolwijk

12/10/2019, 2:17 PM
I'm using JSR-305 annotations: https://kotlinlang.org/docs/reference/java-interop.html#nullability-annotations which works great
➕ 1
View count: 3