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

    Patrick

    10/26/2019, 2:18 PM
    What are your thoughts on committing the .idea file? Does this make sense or are those custom settings for every user?
    k
    k
    +2
    • 5
    • 9
  • i

    ikozlowski

    10/26/2019, 4:39 PM
    I'm trying to write extension for AssertK that will deep compare objects ignoring id. Works well if I use
    T:Any
    but fails when I want to support nullable fields. Any idea how to cast other to not null type so I can access it class.members?
    fun <T : Any?> assertk.Assert<T>.isEqualToIgnoringId(
        other: T
    ) {
        all {
            if (other == null)
                this.isEqualTo(null)
            else
                other?.let { it::class.members }
        }
    }
    k
    • 2
    • 2
  • v

    voldyman

    10/26/2019, 7:01 PM
    I have a C++ library that builds with CMake and i am trying to write a GUI for it in kotlin and i am assuming i'll need to write JNI bindings for the library. i can't figure out how setup the build system for a project with C++ and kotlin/java for the JNI bindings. Any help would be appreciated.
    n
    m
    • 3
    • 7
  • c

    Carson Graham

    10/27/2019, 6:19 PM
    hey I was wondering how I would disable warnings about using unsigned types? I know that they are experemental, I don't want to add @ExperimentalUnsignedTypes hundreds of times in my code. I've tried adding
    tasks.withType<KotlinCompile> {
        kotlinOptions.jvmTarget = "1.8"
        kotlinOptions.freeCompilerArgs += "-Xexperimental=kotlin.ExperimentalUnsignedTypes"
    }
    this to my build.gradle.kts, but it still warns me in intellij
    k
    • 2
    • 2
  • f

    Fudge

    10/27/2019, 8:34 PM
    FIrst time I've seen this and I can't find info about it online. I can do the quick fix, but there has to be some reason it's not enabled by default, right?
    b
    • 2
    • 8
  • k

    karelpeeters

    10/28/2019, 10:14 AM
    Is there a way to only allow a single class
    A
    to instantiate a class
    B
    , while keeping
    B
    itself public? Basically I want
    B
    to have a private constructor that can also be accessed by
    A
    but not by a random class
    C
    . Putting
    A
    and
    B
    is the same file doesn't allow
    A
    to use the private constructor, and even making
    B
    a nested class of
    A
    also doesn't work. Is there a solution?
    d
    d
    p
    • 4
    • 16
  • g

    George Pandian

    10/28/2019, 11:07 AM
    Hi , just wanted to understand what is the main difference between open and sealed class and also the use cases for its usage.
    d
    s
    e
    • 4
    • 4
  • z

    zceejkr

    10/28/2019, 11:47 AM
    Is it possible to make a companion object equal to the output of some function? I am trying to do something like
    companion object : SomeType = someFunc()
    . Or do you always have to declare the companion, as in
    companion object : SomeType {body}
    ?
    👍 1
    d
    m
    +2
    • 5
    • 7
  • z

    zceejkr

    10/28/2019, 12:13 PM
    One more question, would it be possible to override the equals and hashcode methods on the ByteArray from the Kotlin standard library, to check for value equality rather then referential equality? Extension methods seem to be shadowed by member declarations, but is there some other way of doing that or do I have to manually do this in all data classes that contain ByteArrays?
    k
    k
    • 3
    • 8
  • j

    JavierSalazar

    10/28/2019, 3:53 PM
    Hello everone 👋 - just starting out with kotlin and coming from mostly scripting languages I'm really enjoying it n.n
    👏 1
    👍🏼 4
    m
    • 2
    • 2
  • t

    Travis Griggs

    10/28/2019, 5:11 PM
    I don’t understand why this works: val UInt.le_ubytes:UByteArray get() { val quad = (0 until 31 step 8 ).map { shift -> (this shr shift and 0xFFu).ubyte } return quad.toUByteArray() } but this doesn’t work: val UInt.le_ubytes:UByteArray get() { val quad = (0 until 31 step 8 ).map { shift -> (this shr shift and 0xFFu).ubyte } return ubyteArrayOf(*quad) } It hates on the ubyteArrayOf() with the spread operator. It wants a UByteArray as the argument. Which is pointless, because why would I be using the ubyteArrayOf() helper if I had a UByteArray already?
    e
    • 2
    • 2
  • e

    Ellen Spertus

    10/28/2019, 6:45 PM
    To work with a Java API, I need to create a method whose return type is
    Void
    and has the following behavior:
    override fun getResult(): Void {
            if (!success) throw RuntimeException()
        }
    This doesn't compile, because a function with a block body requires a return statement.
    r
    j
    +3
    • 6
    • 20
  • b

    Brais Gabin

    10/28/2019, 7:14 PM
    Is there any channel to talk about kotlin development? I’m running the tests from https://github.com/JetBrains/kotlin/ in my computer and they don’t pass.
    ./gradlew ideaPluginTest
    k
    • 2
    • 1
  • t

    Travis Griggs

    10/28/2019, 9:10 PM
    Simple way to have a closure execute 250.milliseconds in the future? Looking for the Kotroid equivalent of the Swiftios DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(250)) { Foo().makeABar() }
    m
    a
    • 3
    • 5
  • k

    Kroppeb

    10/28/2019, 10:19 PM
    If I have
    sealed class Foo<T:Any> {
    	object Bar : Foo<Nothing>()
    	class Baz(val p: String) : Foo<String>()
    
    	// I can do this
    	fun String.convert() = this.let(::Baz)
    }
    
    // One type argument expected for class Foo<T : Any>
    fun String.convert2() = this.let(Foo::Baz)
    
    typealias FooBaz = Foo.Baz
    
    fun String.convert3() = this.let(::FooBaz)
    I get an error if i try
    Foo::Baz
    but adding a type makes
    Baz
    an unresolved reference. The code does work if all generics are removed. Can I fix this without import statements?
    n
    m
    • 3
    • 2
  • a

    andrzej

    10/29/2019, 11:10 AM
    If I have:
    class Auto(val isNew: Boolean)
    val car: Car? = Car(true)
    why the following code works:
    if (car?.isNew == true) println("new car")
    and the following doesn't compile:
    if (car?.isNew) println("new car")
    d
    a
    +4
    • 7
    • 14
  • s

    Slackbot

    10/29/2019, 1:04 PM
    This message was deleted.
    a
    • 2
    • 1
  • e

    eekboom

    10/29/2019, 1:53 PM
    When I have a chain of collection transformations, is it always possible to easily convert that to operations on a sequence? In other words: Is there any operation that I can use in a chain of collection operations, but not on a sequence?
    m
    b
    • 3
    • 5
  • v

    Vinicius Araujo

    10/29/2019, 3:01 PM
    Collections -> I have a SizedIterable list with dynamic content that came from an inner join statement. How can I map a new list with grouped "father" fields, and add an inner list with child records of each father?
    k
    • 2
    • 7
  • m

    mantono

    10/29/2019, 4:20 PM
    I have an interface with a function that has the signature
    fun <T: Any?> asArray(tClazz: Class<T>): Array<T>
    , how ever, I have no idea how to return an Array of type T in Kotlin on a non-reified function with only the Class as argument.
    d
    m
    w
    • 4
    • 29
  • e

    eekboom

    10/29/2019, 4:34 PM
    Is there something similar to Java’s Stream.Builder? Something that I can pass around and let code add values to and finally create a Sequence? I mean I can always use a mutable list, but I like the smaller API of Stream.Builder.
    o
    • 2
    • 4
  • j

    jimn

    10/29/2019, 5:31 PM
    when does Regex("1+2") (or "(1)+2" )fail to match "12" ?
    w
    • 2
    • 3
  • t

    Travis Griggs

    10/29/2019, 5:55 PM
    I hate Java’s lack of unsigned values, particularly that “Byte” should have ever been signed. So I’m loving Kotlin’s Unsigned stuff, especially UByte(Array). Is there any reason NOT to embrace UByte(Array) throughout my app and just translate to/from at the edges when using Android APIs? For example, performance penalties? I notice that there doesn’t seem to be a UByteArrayInput/OutputStream, but I can probably make my own of those.
    b
    k
    • 3
    • 2
  • p

    Paul Woitaschek

    10/29/2019, 7:15 PM
    What do you use for mocking? Mockitos support for Kotlin is kinda meh, especially with coroutines and mockk seems kinda abandoned. There are lots of blockers and the author recently wrote that he has no time for mockk any longer.
    w
    s
    +3
    • 6
    • 10
  • t

    Travis Griggs

    10/30/2019, 12:45 AM
    Is there some trick to getting project wide Unsigned support? I tried:
    s
    a
    • 3
    • 6
  • w

    william

    10/30/2019, 3:30 AM
    is there a more kotlin idiomatic way of doing this?
    for (i in 0..fooCount) {
                foos.add(bar.getFoo(i))
            }
    j
    k
    • 3
    • 5
  • k

    Krotick

    10/30/2019, 4:09 AM
    I am using DynamDBMapper annotations on a data class (AWS Java SDK). I am trying to get back the methods that have a particular annotation, and I am getting nothing, even though annotations on the class itself are shown. Is there something that I am missing when retrieving method annotations? (see thread for details)
    s
    • 2
    • 5
  • c

    chandrut

    10/30/2019, 7:20 AM
    Folks, I am using KTOR/KOTLIN/NETTY and looking for monitoring tool like new relic or javamelody that support coroutines can you please help me with tool that finds hotspots in code/ and profiles time spent with GUI
    • 1
    • 1
  • u

    Uziel Sulkies

    10/30/2019, 11:59 AM
    I was just astonished to find out that Map.getValue(key) does not guarantee non-null value. If a map has explicit null value for a key, this method will return null !
    Map getValue can return null!
    🤯 1
    d
    a
    • 3
    • 6
  • s

    Slackbot

    10/30/2019, 12:09 PM
    This message was deleted.
    a
    • 2
    • 1
Powered by Linen
Title
s

Slackbot

10/30/2019, 12:09 PM
This message was deleted.
a

Ari Dwi Prayogo

10/30/2019, 12:09 PM
#multiplatform
👍 1
View count: 2