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

    ilya.gorbunov

    12/18/2017, 3:41 AM
    @thomasnield Unfortunately there's no way for consumer of an Iterator to convey though its interface that it's not going to be iterated anymore.
    t
    • 2
    • 2
  • l

    louiscad

    12/18/2017, 1:39 PM
    Any library devs that can help me on this?
    c
    c
    • 3
    • 6
  • l

    louiscad

    12/18/2017, 3:04 PM
    This is ugly:
    val thisIsAByte: Byte = getValueFromMagic()
    when (thisIsAByte) {
        0x00.toByte() -> LOCKED
        0x01.toByte() -> UNLOCKED
        0x02.toByte() -> UNLOCKED_AND_AUTO_RELOCK_DISABLED
        else -> throw IllegalStateException("Unexpected value for lockState: $it")
    }
    Hope we will soon be able to get rid of the
    toByte()
    calls
    g
    • 2
    • 4
  • n

    nish

    12/18/2017, 3:14 PM
    Does anyone have any information about how the kotlin jvm source maps work?
    g
    • 2
    • 2
  • s

    Shawn

    12/18/2017, 6:09 PM
    that is kinda weird, dunno why invoking
    println
    would need to care about coercing
    Int?
    to
    Int
    👍 1
    a
    b
    • 3
    • 3
  • i

    iex

    12/18/2017, 10:57 PM
    but it's necessary, otherwise
    Result
    doesn't know which value it contains!
    n
    • 2
    • 2
  • n

    nyxcharon

    12/19/2017, 6:41 PM
    Does anyone know if there is a way to verify code snippets in Kotlin docs? For example if I document a function and include an example of how to use it, to verify that it works as intended? Similar to rust or python? Example for python: https://docs.python.org/2/library/doctest.html
    s
    i
    d
    • 4
    • 8
  • s

    shayla

    12/19/2017, 6:49 PM
    Hello everyone! New to this slack, so please let me know if I am posting in the wrong channel. I am in the middle of creating a kotlin library that has wrapped some of its functionality in coroutines. My understanding is that coroutines are not accessible when calling from Java. Has anyone come up with a good way to provide similar functionality to Java projects? I would prefer to stay away from RxJava - was hoping there was a smart way to use kotlin to do this.
    s
    • 2
    • 3
  • b

    bj0

    12/19/2017, 10:05 PM
    is there a way to create a single element
    Iterable
    without creating an array or list?
    a
    t
    p
    • 4
    • 17
  • k

    kevinmost

    12/19/2017, 11:49 PM
    hm, weird, it's working for me, it resolves the extension method when I do:
    val str = "Foo"
            val str2 = "foo"
            str.equals(str2, ignoreCase = true)
    i
    a
    • 3
    • 2
  • a

    alexcouch

    12/20/2017, 12:06 AM
    How come so many files in the stdlib are classes rather than kotlin files?
    i
    • 2
    • 2
  • o

    oblakr24

    12/20/2017, 7:05 AM
    Do you prefer a lambda initializer ( { SomeClass() } ) or reflection with classes ( SomeClass::class.java )? I like lambdas much more, but which is more performant?
    g
    • 2
    • 4
  • o

    ontherunvaro

    12/20/2017, 9:49 AM
    Is it better to use
    variable?.let{...}
    or
    if (variable != null) {...}
    ?
    g
    • 2
    • 5
  • k

    karelpeeters

    12/20/2017, 10:39 AM
    Would it help if
    append
    was inline? Or am I misunderstanding the issue?
    g
    • 2
    • 1
  • j

    jstuyts-squins

    12/20/2017, 12:21 PM
    I believe the idea is to use the GUI framework of the Kotlin platform: JVM → Spring/JavaFX, Native → iOS/Android/Windows/macOS
    t
    r
    • 3
    • 2
  • g

    GauthierPLM

    12/20/2017, 12:50 PM
    Is there any kotlin wrapper around the browser API to build extensions?
    g
    k
    • 3
    • 4
  • m

    michael salmon

    12/20/2017, 3:18 PM
    ok cool, i refactored the extra classes in KeyGrantController to separate .kt files, but KeyGrantController.kt icon didn’t change and I restarted IJ
    a
    e
    • 3
    • 5
  • m

    Michael Wilson

    12/20/2017, 6:00 PM
    Aloha, friends. I'm somewhat new to Kotlin and absolutely loving it. I've been working in Java, Go, and the various Cs for years. I get so much more done. But, I have a question, and I'm not hoping for a sales pitch, but an honest evaluation. I working with some others on an open source, non-profit project. It's an api and a set of consumer apps centered around open science and environmental conservation. It looks like we'll have some funding for a core team, but I wanted to make the entry easy for the open source community to get involved. I'd really love to use Kotlin, as we could share a lot of the core logic between Android, Native, Server, and Devops. But, I'm not sure if there are enough Kotliners out there to have an impact on an open source project. My other alternative is to cobble together PHP, Ruby, Cordova, etc, which I really don't want to do. Does anyone else have experience with this kind of decision? Is it too hard to find kotliners for open source projects? I know its a pretty low learning curve, but it still exists. Is the brevity and code reuse worth the trade-off of a limited talent pool? Really appreciate any feedback.
    t
    j
    +2
    • 5
    • 14
  • t

    Tachyon

    12/20/2017, 6:03 PM
    so, I had some kind of event handler in java which worked, but now since I converted to kotlin it doesn't anymore. I am checking if (java) event Class isInstance with the method I have, and it returns true, but then if I try to method.invoke(method), it throwns an exception about "object is not an instance of declaring class". what can I do ?
    a
    • 2
    • 1
  • m

    markusa

    12/20/2017, 7:12 PM
    But I guess the compiler is putting in the expression string as a parameter, so I'm wondering if there is another way to get an expression at runtime
    k
    • 2
    • 2
  • p

    pedroveronezi

    12/20/2017, 9:01 PM
    Hi everybody, I'm brazilian and I'm new in here, my english is not too good, but I hope to learn and make some friends on the way.
    👋 8
    🇧🇷 2
    :kotlin-flag: 2
    c
    • 2
    • 1
  • x

    xenoterracide

    12/21/2017, 4:36 AM
    I wouldn't advise field hiding
    e
    • 2
    • 16
  • x

    xenoterracide

    12/21/2017, 7:33 AM
    is there a better way to do this?
    url = uri(System.getenv("JRS_S3_URI") ?: uri(""))
    q
    j
    • 3
    • 17
  • o

    Olekss

    12/21/2017, 7:44 AM
    Hi. Is there clean way in Kotlin to get list of properties of given Instance. Each individual and known property would be like ::property but I want to get list of all - without diving into actual java low-level reflection BS
    q
    • 2
    • 2
  • e

    elect

    12/21/2017, 10:06 AM
    sorry, but I think I'm mixing things up, what do I need for kotlin eap
    maven { url "<https://dl.bintray.com/kotlin/kotlin-dev>" }
    maven { url "<https://dl.bintray.com/kotlin/kotlin-eap>" }
    The first one? The second one? I cant test, because I have already everything cached and I'd need to delete (and download again) gb of stuff (.gradle) just to try
    g
    • 2
    • 9
  • j

    jw

    12/21/2017, 5:25 PM
    not sure why Deque gets no love in the jdk stdlib, but that'd sure look nicer with
    arrayDequeOf(this)
    👍 1
    g
    • 2
    • 3
  • s

    Shawn

    12/21/2017, 5:52 PM
    are you like writing a Kotlin fundamentals blog post or something similar?
    t
    • 2
    • 1
  • s

    Shawn

    12/21/2017, 8:06 PM
    oh, maybe it’s because the share arrow kinda resembles a reply arrow 🤔
    c
    • 2
    • 1
  • o

    orangy

    12/21/2017, 8:46 PM
    📣 pretty please, use threads :thread-please: instead of quoting messages
    👍 19
    g
    l
    • 3
    • 2
  • b

    bj0

    12/21/2017, 10:55 PM
    is there a stdlib way of replacing a pattern of bytes in a bytearray?
    l
    k
    • 3
    • 4
Powered by Linen
Title
b

bj0

12/21/2017, 10:55 PM
is there a stdlib way of replacing a pattern of bytes in a bytearray?
l

louiscad

12/21/2017, 10:58 PM
I don't think so. There's not much in byte operations in stdlib at of 1.2. Only the basic stuff which you can build upon
b

bj0

12/21/2017, 10:59 PM
yea I can't find anything or think of a functional way to do it
k

karelpeeters

12/21/2017, 11:09 PM
Can you give an I/O example?
b

bj0

12/21/2017, 11:43 PM
IO example? I'm just trying to replace 2-byte "escape" sequences with their corresponding byte
View count: 4