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

    Lukas Cardot

    04/16/2019, 7:45 AM
    Please strart using threads 🙏
    s
    m
    2 replies · 3 participants
  • p

    Paul Woitaschek

    04/16/2019, 8:27 AM
    Why isn't this a valid contract? It says "Only references to parameters are allowed in a contract description". What does that mean?
    Untitled.kt
    h
    s
    4 replies · 3 participants
  • j

    jpfarias

    04/16/2019, 10:31 AM
    hey guys, what is the kotlin equivalent of java's
    private float[][] labelProbArray = new float[1][256*256]
    ?
    🤣 1
    :google: 2
    :stackoverflow: 2
    m
    t
    +1
    5 replies · 4 participants
  • j

    jpfarias

    04/16/2019, 11:20 AM
    to put in context, I am working with opencv and tensorflow lite and coverting to / from one another is driving me mad
    :thread-please: 1
    k
    1 reply · 2 participants
  • c

    camdenorrb

    04/16/2019, 11:31 AM
    How can I call the super method for this in an implementation?
    r
    h
    +3
    32 replies · 6 participants
  • m

    Marc Reichelt

    04/16/2019, 1:59 PM
    I am creating a Kotlin Community within my company. What are good rewards to give away to coworkers who start using Kotlin in their projects, or are doing good within the community? Suggestions would be nice 🙂
    l
    t
    +5
    22 replies · 8 participants
  • l

    LeoColman

    04/16/2019, 3:59 PM
    Do you guys know if there's any particular reason for
    Char.isDigit
    to not have it's opposite
    Char.isNotDigit
    ?
    a
    l
    +1
    6 replies · 4 participants
  • t

    tristan bergh

    04/16/2019, 4:43 PM
    hi tristan bergh here. I'm a data scientist looking to use kotlin for data science
    s
    c
    +1
    3 replies · 4 participants
  • a

    Andrew Gazelka

    04/16/2019, 7:05 PM
    We can refer to a method
    foo()
    of class
    Bar
    Bar#foo()
    . Is it appropriate to reference property
    baz
    of
    Bar
    as
    Bar#baz
    ?
    r
    5 replies · 2 participants
  • s

    Smallville7123

    04/16/2019, 7:18 PM
    is this condensable?
    if (expansion.length != 0)
        if (expansion.last().equals(' ')) return expansion.dropLast(1).toString()
    return expansion.toString()
    l
    r
    +2
    8 replies · 5 participants
  • a

    alexsullivan114

    04/16/2019, 8:46 PM
    I'm finding myself getting frustrated with the fact that Kotlins optionals aren't actually
    Optional
    objects. Am I missing something here?
    :yes: 1
    j
    c
    14 replies · 3 participants
  • j

    jw

    04/16/2019, 8:47 PM
    sounds like you're missing a heap allocation and pointer indirection
    ➕ 2
    😂 2
    s
    1 reply · 2 participants
  • s

    Smallville7123

    04/17/2019, 4:06 AM
    is https://github.com/xenomachina/kotlin-argparser a good argument parsing library or are there better ones?
    g
    3 replies · 2 participants
  • s

    Smallville7123

    04/17/2019, 4:47 AM
    -.kt
    n
    k
    34 replies · 3 participants
  • t

    thana

    04/17/2019, 6:19 AM
    i have a sealed class with about 10 subclasses (and growing). now i need to map them to a frontend model. so i end up with a huge
    when
    statement which is more or less unreadibl. so again i end up with a visitor for this class. how do you handle this situation?
    k
    s
    6 replies · 3 participants
  • s

    Smallville7123

    04/17/2019, 8:07 AM
    are there any kotlin libraries for creating Command Line Shells from, as i cant find any online, just stuff about kotlin compiler and the kotlin REPL
    g
    11 replies · 2 participants
  • l

    lkonya

    04/17/2019, 9:00 AM
    Hi guys! Is there a way, to include annotation processed files into zip? I have a task:
    task buildZip(type: Zip) {
        from compileKotlin
        from processResources
        into("lib") {
            from configurations.compileClasspath
        }
    }
    But this include only the classes I created, not classes created by annotation processing. The build process create the classes made by annotation processing under
    tmp/kapt3/classes/main
    . Do you know a way to include these files as well?
    1 reply · 1 participant
  • j

    JM Santos

    04/17/2019, 9:59 AM
    But the problem is we need to support 23 (which is a low version)
    m
    1 reply · 2 participants
  • c

    carlos cdmp

    04/17/2019, 10:30 AM
    After a list filter, I have to cast it to the filtered type, like
    list.filter { it is A }.forEachIndexed { index, item -> (item as A)
    Is there any way to smartcast it?
    g
    r
    4 replies · 3 participants
  • l

    Lawik

    04/17/2019, 11:54 AM
    Does anyone know whether this is possible using reflection only?
    (person::class.companionObjectInstance as PersonDTO.Companion)
    (person is an instance of PersonDTO)
    r
    17 replies · 2 participants
  • j

    JM Santos

    04/17/2019, 2:46 PM
    Thanks guys for help regarding the timezone issues. We ended up with Joda because it supports our lowest version (23). Great help! 👏
    r
    1 reply · 2 participants
  • h

    Hullaballoonatic

    04/17/2019, 7:58 PM
    also can you conceive of a possibility where brackets could and should be omitted? i'm thinking things like 1 line lambda functions, e.g.
    list.any it.hasFoo
    c
    b
    5 replies · 3 participants
  • a

    Andrew Gazelka

    04/17/2019, 7:58 PM
    I don't want the constructor of a data class to be accessible outside a file. Is this a good way to do it? (also what you think of code...)
    k
    s
    +2
    21 replies · 5 participants
  • h

    Hullaballoonatic

    04/17/2019, 8:00 PM
    i tend to prefer the following when working with non-traditional class constructors:
    data class Foo {
        companion object {
            operator fun invoke(): Foo {
            
            }
        }
    }
    a
    b
    +1
    12 replies · 4 participants
  • c

    Casey Brooks

    04/17/2019, 8:30 PM
    Is it possible to use property delegates with the
    by
    keyword on extension properties, so that I can pass
    this
    through to the delegate?
    s
    3 replies · 2 participants
  • p

    Patrick Jackson

    04/17/2019, 8:34 PM
    Anyone regex experts know how to include foreign chars in this expression?
    "[^\\p{Alnum}]".toRegex().find("s.trim μεγιουνικουντ n/o/n a.lph.a n.um\"")
    Works in Java with:
    p = Pattern.compile("[^\\p{Alnum}]", Pattern.UNICODE_CHARACTER_CLASS);
    however do not see an equivalent in Kotlin
    c
    p
    5 replies · 3 participants
  • h

    Hawk

    04/17/2019, 9:58 PM
    Hey, I have a weird one. I have a project that is currently building fine on a colleagues windows pc, it also builds fine on our TeamCity agent. However, on my pc Windows 1809, I get the following exception (will post below). I've tried
    mvn package
    on wsl (ubuntu 1804) using the default jdk (10) as well as openjdk11 both give the same error. Same error when I try and run from intellij (right click green arrow -> run ). Any ideas 😕
    a
    1 reply · 2 participants
  • b

    bloder

    04/17/2019, 10:43 PM
    Hey guys, a doubt about
    inline class
    what happens if I have an inline class as parameter of another inline class?
    inline class Bar(val number: Int)
    inline class Foo(val bar: Bar)
    
    Foo(Bar(1)) == 1?
    b
    4 replies · 2 participants
  • s

    Smallville7123

    04/18/2019, 5:35 AM
    R
    represents a
    kotlin.function
    right? thus
    fun a(R) {
        R.invoke()
    }
    will take a function accepting 0 parameters, then execute that function right?
    g
    t
    +2
    207 replies · 5 participants
  • s

    Slackbot

    04/18/2019, 8:01 AM
    This message was deleted.
    p
    s
    3 replies · 3 participants
Powered by Linen
Title
s

Slackbot

04/18/2019, 8:01 AM
This message was deleted.
p

Pavlo Liapota

04/18/2019, 8:21 AM
if (line.startsWith('/')) line.drop(1) else line
or
line.let {
    if (it.startsWith('/')) it.drop(1) else it
}
s

Smallville7123

04/18/2019, 8:27 AM
but i want to retain the result of the original expression
so i can use it with
if (line.startsWith('/')) {
                line.drop(1)
                val str = StringBuilder()
                val parser = Parser(line.toStack())
                // modify the following, pulled from "fun String.collapse(token: String, replaceWith: String): String"
                val t = parser.IsSequenceOneOrMany(" ")
                while (parser.peek() != null) {
                    if (t.peek()) {
                        t.pop()
                        str.append(replaceWith)
                    }
                    else str.append(parser.pop()!!)
                }
            }
but make the drop(1) part of the if expression itself
View count: 2