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

    snowe

    07/10/2018, 3:53 PM
    I can accomplish this with star types, but I'd rather have the type safety (and also the intellij help from knowing the type)
    a
    k
    a
    • 4
    • 13
  • f

    frellan

    07/10/2018, 9:13 PM
    When creating a class from another class which have the exact same field names as the parameters for the constructur, like this:
    fun fromData(data: Food) = DTOFood(
      id = data.id,
      whenCreated = data.whenCreated,
      whenModified = data.whenModified,
      singularName = data.singularName,
      pluralName = data.pluralName,
      singularNameIsStandard = data.singularNameIsStandard,
      searchTags = data.searchTags,
      category = data.category
    )
    Is there like a helper function available or how do you write a helper function like that to avoid having to do this?
    m
    a
    a
    • 4
    • 3
  • a

    Alan Lee

    07/10/2018, 9:44 PM
    What you think about having additional parameterized constructor that would be used to pass in mock objects for unit testing only? Would you consider it a bad design since test only code is being inserted to production code? I’m working on a very small project and do not want to add the complexity of a dependency injection framework and thinking about injecting mocks into the class this way only when doing unit testing. Wondering if people find this as a bad design. Another way would be
    @VisibleForTesting
    annotation to assign mocks to variables directly but I find injecting mocks via the constructor is easier to read and clarify which objects needs to be mocked.
    s
    • 2
    • 29
  • n

    nwh

    07/10/2018, 10:24 PM
    I know this is a total non-issue, but why does adding kotlin to a
    build.gradle
    require so many steps? Groovy, for example, only requires
    apply plugin: 'groovy'
    . Just curious about this
    a
    • 2
    • 7
  • m

    mp

    07/10/2018, 10:35 PM
    Are there interfaces associated with overloadable operators? E.g. a
    Plus
    for the
    plus()
    method. It would be great to be able to define
    sum()
    on an
    Iterable<Plus>
    , for instance.
    a
    n
    • 3
    • 7
  • a

    Alan Lee

    07/10/2018, 11:16 PM
    Is there a better unit test code coverage tool than Jacoco for Kotlin ? It appears Jacoco analyzes the byte code generated from Kotlin compiler so results are slightly off from what you would expect from reading Kotlin source code.
    n
    c
    • 3
    • 5
  • a

    Alin B.

    07/11/2018, 9:48 AM
    What would be the right way to generate an UUID in kotlin?
    a
    g
    c
    • 4
    • 16
  • e

    emmax

    07/11/2018, 11:45 AM
    I just noticed the source link for Unit is broken on the kotlinlang website. Wasn't sure the best place to report... https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html Click on the Unit source link. It looks like the latest version isn't there, because if you change the url from https://github.com/JetBrains/kotlin/blob/1.2.51/core/builtins/src/kotlin/Unit.kt#L22 to (1.2.50) its there https://github.com/JetBrains/kotlin/blob/1.2.50/core/builtins/src/kotlin/Unit.kt#L22
    ✅ 1
    🕵️‍♂️ 1
    👍 1
    i
    • 2
    • 1
  • a

    Andreas Sinz

    07/11/2018, 12:42 PM
    @Gta there is no
    then
    in kotlin
    c
    • 2
    • 2
  • c

    Can Orhan

    07/11/2018, 3:01 PM
    When should I consider making a function
    infix
    ? Is there a rule of thumb? Is it worth considering when writing a sort of DSL?
    h
    g
    • 3
    • 4
  • t

    temp_man

    07/11/2018, 9:37 PM
    Just ran this and it works, time to clean it up. Thanks @karelpeeters and @Seri
    👍 2
    k
    • 2
    • 2
  • s

    SSHT

    07/12/2018, 8:38 AM
    Hi, what is the possible ways to localize enum ?
    :stackoverflow: 3
    c
    g
    +2
    • 5
    • 21
  • j

    Jan Vomlel

    07/12/2018, 10:04 AM
    What does mean "Replacing Cs with Ks in libraries"? https://pusher.com/state-of-kotlin
    k
    • 2
    • 5
  • t

    tomtau

    07/13/2018, 8:59 AM
    A question came up on another Slack: what's the best way to diff two huge data classes? https://github.com/SQiShER/java-object-diff ?
    k
    • 2
    • 1
  • e

    elect

    07/13/2018, 9:54 AM
    isn't there another better stlib fun instead calling
    dropWhile
    +
    drop
    ?
    if (file.exists())
            file.readLines()
                    .dropWhile { !it.startsWith('#') }.drop(1)
    d
    b
    +2
    • 5
    • 12
  • t

    Thanos Psaridis

    07/13/2018, 11:21 AM
    @Lucas Ł I'll be damned it worked! You don't know how many hours you saved me I tried everything from sublist to Arraylist(listToBeCopied) my last resort was to json serialize the whole shit and deserialize it again hoping this would make a new deep copy of object inside the list
    k
    • 2
    • 2
  • l

    Lucas Ł

    07/13/2018, 11:22 AM
    you're welcome 😂, another way would be to make the object Parcelable and re-create it
    👎 1
    💯 1
    👍 1
    k
    • 2
    • 2
  • k

    karelpeeters

    07/13/2018, 1:41 PM
    It would need to cover things like
    val y = x++
    too. I'd say submit a YouTrack issue.
    👍 1
    a
    • 2
    • 2
  • u

    ubu

    07/13/2018, 2:50 PM
    Hi there. Is there some alternative in
    Kotlin
    to Guava's
    EvictingQueue
    ? https://google.github.io/guava/releases/15.0/api/docs/com/google/common/collect/EvictingQueue.html
    f
    • 2
    • 6
  • n

    Nikky

    07/14/2018, 12:42 AM
    is there any tool to translate lombok-java into kotlin ?
    s
    • 2
    • 2
  • a

    Aregev2

    07/15/2018, 2:42 PM
    Are we allowed to write our own kotlinx libraries ?(ie kotlinx.SOMELIBRARY)
    k
    g
    h
    • 4
    • 18
  • s

    Shawn

    07/15/2018, 10:18 PM
    I mean, if “intelligibility” is your goal, why not just manually null-check? it’s about the same number of characters
    v
    • 2
    • 1
  • p

    pp.amorim

    07/16/2018, 9:58 AM
    @karelpeeters there is something similar
    k
    • 2
    • 6
  • e

    elect

    07/16/2018, 1:20 PM
    is it a design or technical reason to allow destructurization only for local variables and lambdas? I'm looking for top level variables
    p
    a
    k
    • 4
    • 5
  • e

    Edwin Miguel

    07/16/2018, 8:33 PM
    Hello, currently I'm working with a legacy method that throws an exception when error occurs. I could wrap it with a new one and rethrow to an upper layer, but also, I could create a sealed class to represent the response of the method (success or error). What do you think is the best approach. I would prefer to used sealed classes (or maybe a functional Either) than rethrowing errors.
    n
    • 2
    • 5
  • h

    hhariri

    07/17/2018, 2:18 PM
    <!here> It’s not often that we use notifications on #general, but today calls for a celebration. If you haven’t noticed, you now have history in Slack! We’re extremely grateful to Slack and specifically to @sam for helping put this in motion.
    🍺 21
    🐎 3
    🐘 6
    💥 16
    😻 1
    🕶️ 2
    🚀 6
    👻 16
    💯 40
    👍 74
    ⬆️ 1
    🤠 4
    🥂 19
    😒lack: 132
    📖 20
    👙 1
    🍾 16
    :yes: 8
    🎉 249
    🎇 15
    😺 2
    :thumbsup_all: 12
    :trollface: 2
    🔥 38
    🤘 1
    ❤️ 102
    🎖️ 3
    :kotlin-flag: 11
    🐔 3
    🕴️ 16
    🍂 16
    😯 16
    🤘 14
    :kotlin: 95
    👌 37
    🎊 32
    👏 40
    :gradle: 23
    r
    n
    +6
    • 9
    • 15
  • e

    enleur

    07/17/2018, 2:50 PM
    is this the first community who has slack subscription?
    g
    • 2
    • 1
  • s

    s1m0nw1

    07/17/2018, 2:57 PM
    And now's a good time to ask: Should we be posting our knowledge to this isolated platform which is not indexed by search engines? Doesn't this slow down the dissemination of knowledge? 🤔 (I know, many channels aren't affected by this)
    👍 4
    n
    e
    +2
    • 5
    • 10
  • a

    Aregev2

    07/17/2018, 5:41 PM
    Can we access the JNI via Kotlin? (where is the
    native
    keyword)
    f
    • 2
    • 2
  • v

    Venkatesh-Prasad Ranganath

    07/17/2018, 6:08 PM
    What’s the recommended way to use kotlin.test or kotlintest in IntelliJ projects?
    s
    • 2
    • 6
Powered by Linen
Title
v

Venkatesh-Prasad Ranganath

07/17/2018, 6:08 PM
What’s the recommended way to use kotlin.test or kotlintest in IntelliJ projects?
s

snowe

07/17/2018, 6:18 PM
what do you mean?
v

Venkatesh-Prasad Ranganath

07/17/2018, 6:53 PM
How do you add kotlin.test library to an IntelliJ project to use assertion functions and annotations in tests? Same question about kotlintest.
s

snowe

07/17/2018, 7:07 PM
are you using maven or gradle?
v

Venkatesh-Prasad Ranganath

07/17/2018, 7:35 PM
None. Just IntelliJ.
I am trying to set it all up to run the tests from IntelliJ.
s

snowe

07/17/2018, 8:47 PM
If you aren't using maven or gradle, you'll need to add the kotlin.test jar to the classpath yourself.
View count: 97