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
stdlib
  • a

    anstaendig

    09/13/2017, 12:11 PM
    I might be misusing
    run()
    . I tend to use it in cases where I would combine
    let()
    and `with()`…
    i
    • 2
    • 1
  • e

    elect

    09/21/2017, 11:39 AM
    small thing: may we introduce
    pathOf(String/URI)
    ?
    k
    v
    • 3
    • 10
  • h

    holgerbrandl

    09/29/2017, 8:20 AM
    Indeed @gaetan. Does kotlin-
    log
    at least provide
    e
    as default for the base? Because if so users could keep using
    log
    as natural logarithm. LIke in python https://docs.python.org/2/library/math.html#math.log or R http://astrostatistics.psu.edu/su07/R/html/base/html/Log.html
    g
    g
    e
    • 4
    • 11
  • d

    dmitry.petrov

    10/09/2017, 5:24 PM
    Currently "containers" (in general) in Kotlin are just library classes. There's nothing "special" about them. On one hand, it gives additional flexibility - like, you can potentially have containers with side effects in container operations. On the other hand, compiler (and JIT) can't perform optimizations that, for example, skip some operations (like creating an intermediate container), or change evaluation order. Since most collection operations work with abstract collections, you can't do such optimizations "in general". We have some ongoing discussion about collection literals & loop fusion (you'd usually call that "deforestation" in functional context). In 1.4 scope, maybe.
    k
    • 2
    • 1
  • e

    elect

    10/09/2017, 5:45 PM
    could we always resolve
    x += y
    with
    plusAssign
    and
    x + y
    with
    plus
    ? It's really a pity to give up on that because of ambiguity
    d
    k
    • 3
    • 18
  • k

    karelpeeters

    10/12/2017, 6:58 AM
    I finally got annoyed enough to create an issue about the name: https://github.com/DemonWav/kotlin-utils/issues/1
    g
    • 2
    • 1
  • k

    karelpeeters

    10/12/2017, 9:21 AM
    That's actually where I found the library.
    u
    • 2
    • 2
  • u

    uli

    10/12/2017, 11:28 AM
    Remains the discussion if exceptions thrown by close during exception handling should be `addSuppressed`or silently ignored. Any one knows, why the author of
    use {}
    decided to ignore them?
    i
    • 2
    • 6
  • k

    karelpeeters

    10/15/2017, 7:18 PM
    I'd link to your comment here from #general.
    d
    • 2
    • 2
  • m

    Marc Knaup

    10/21/2017, 3:52 PM
    val Class<*>.boxed
    	get() =
    		if (isPrimitive)
    			when (this) {
    				Boolean::class.java -> java.lang.Boolean::class.java
    				Char::class.java -> java.lang.Character::class.java
    				Byte::class.java -> java.lang.Byte::class.java
    				Short::class.java -> java.lang.Short::class.java
    				Int::class.java -> java.lang.Integer::class.java
    				Long::class.java -> java.lang.Long::class.java
    				Float::class.java -> java.lang.Float::class.java
    				Double::class.java -> java.lang.Double::class.java
    				Void.TYPE -> java.lang.Void::class.java
    				else -> error("Unexpected primitive class: $this")
    			}
    		else
    			this
    
    
    fun Class<*>.isAssignableOrBoxableTo(otherClass: Class<*>) =
    	otherClass.isAssignableOrBoxableFrom(this)
    
    
    fun Class<*>.isAssignableOrBoxableFrom(otherClass: Class<*>) =
    	boxed.isAssignableFrom(otherClass.boxed)
    🤔 Would that be useful for stdlib?
    e
    i
    • 3
    • 6
  • j

    jw

    11/01/2017, 9:43 PM
    actually i'm not even sure it should exist
    k
    k
    • 3
    • 12
  • h

    holgerbrandl

    11/10/2017, 7:05 AM
    When writing an API is there a way to finetune via annotations for which method parameters the user should get parameter hints in in intellij?
    v
    • 2
    • 6
  • d

    Dmitry Kandalov

    11/23/2017, 4:05 PM
    I think there is a typo in kotlindoc for
    trimStart()
    , it shouldn't say " and trailing". https://github.com/JetBrains/kotlin/blob/1.1.60_173/libraries/stdlib/src/kotlin/text/Strings.kt#L106 https://github.com/JetBrains/kotlin/blob/1.1.60_173/libraries/stdlib/src/kotlin/text/Strings.kt#L111
    i
    • 2
    • 5
  • h

    holgerbrandl

    11/24/2017, 7:27 AM
    @dave @raulraja Thanks for the support. I’ve filed https://youtrack.jetbrains.com/issue/KT-21426
    👏 1
    h
    • 2
    • 2
  • r

    raulraja

    12/03/2017, 12:33 AM
    I wish Kotlin returned
    A?
    in those types of operations that throw exceptions because the only possible error in that context is being out of range.
    o
    • 2
    • 1
  • m

    madorb

    12/04/2017, 9:48 PM
    so, i just asked this in general, but i see this the questions here are related… is there any commonly-used library, that’s like “kotlin: the missing bits” that extends the stdlib with various convenience functions that perhaps haven’t yet made it into the stdlib?
    e
    • 2
    • 8
  • e

    elect

    12/05/2017, 11:31 AM
    one thing that I think may be source of bug about ranges is that
    0 until x
    is
    [0, x)
    , but
    x downTo 0
    is
    [x, 0]
    d
    • 2
    • 2
  • k

    karelpeeters

    12/05/2017, 11:55 AM
    Another related issue, a while ago I was looking for something
    x to y
    that returns a sequence that goes into whatever direction is required, for example:
    0 to 5
    is
    [0,1,3,4]
    and
    0 to -5
    is
    [0,-1,-2,-3,-4]
    .
    i
    • 2
    • 1
  • k

    kingsley

    12/05/2017, 3:43 PM
    There isn’t anything like that in stdlib AFAIK. A simple extension like this (end inclusive) should suffice though
    infix fun Int.through(end: Int): IntProgression {
        return if (end > this) this..end else this downTo end
    }
    
    fun main(args: Array<String>) {
        (0 through 5).forEach(::println)
        (4 through -3).forEach(::println)
    }
    g
    • 2
    • 1
  • d

    damian

    12/08/2017, 6:14 PM
    Whatever happened to kotlinx persistent collections? Last I heard, there was some talk about them not implementing the collection interfaces to fix the operator overload problem, I think... looks like the repo hasn't moved in some time https://github.com/Kotlin/kotlinx.collections.immutable
    i
    • 2
    • 1
  • n

    natpryce

    12/10/2017, 2:57 PM
    I’ve implemented it as a sequence wrapper. Is there interest in including it in the stdlib? If so i can send in a PR
    d
    • 2
    • 2
  • l

    louiscad

    12/18/2017, 10:35 AM
    Hi, why bitwise operations on
    Byte
    and
    Short
    are marked as experimental in the stdlib?
    k
    g
    r
    • 4
    • 5
  • j

    jw

    01/12/2018, 4:42 AM
    it's for multiplatform projects to link against
    a
    g
    p
    • 4
    • 6
  • v

    vmichalak

    01/12/2018, 6:47 PM
    I doesn't find Random class or Time Manipulation API on stdlib. For the moment stdlib is very small.
    g
    • 2
    • 2
  • r

    raulraja

    01/12/2018, 10:53 PM
    @voddan if they are going to be cross platform would the JVM one based in the JDK classes or are these complete new implementations?
    v
    • 2
    • 1
  • k

    karelpeeters

    01/13/2018, 12:11 AM
    https://xkcd.com/927/ comes to mind.
    😂 4
    v
    • 2
    • 1
  • g

    groostav

    01/15/2018, 4:07 AM
    is there a discussion about including a
    fun java.io.Reader.asCharSequence(decoding: Charset = Charsets.UTF_8)): Sequence<Char>
    --or other wrappers on
    <http://java.io|java.io>
    classes in the std-lib?
    i
    • 2
    • 1
  • r

    raulraja

    01/24/2018, 11:07 PM
    Is there an ETA for Kotlin immutable collections or is that on hold?
    g
    e
    • 3
    • 2
  • s

    sxtanna

    02/03/2018, 10:22 PM
    Is there any particular reason there is no
    toMap()
    function available as an extension on a collection of
    Map.Entry<K, V>
    ?
    a
    i
    • 3
    • 23
  • h

    hho

    02/05/2018, 9:43 AM
    But you can of course do
    "your string".substring(startIndex).matches(regexp)
    u
    • 2
    • 1
Powered by Linen
Title
h

hho

02/05/2018, 9:43 AM
But you can of course do
"your string".substring(startIndex).matches(regexp)
u

uhe

02/05/2018, 9:52 AM
whenever I see
substring
I automatically see
StringIndexOutOfBoundsException
😄
View count: 1