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

    Slackbot

    08/26/2021, 3:21 AM
    This message was deleted.
    :stackoverflow: 2
    :google: 1
    :not-kotlin: 1
    r
    • 2
    • 1
  • i

    iamthevoid

    08/27/2021, 2:52 PM
    Poor example, but can i somehow use
    this
    reference in
    lazy { }
    scope for extension val ? Something like that:
    val String.something by lazy { "$this$this" }
    l
    r
    y
    • 4
    • 8
  • l

    LeoColman

    08/29/2021, 6:07 PM
    Hi guys! Do you see a way to reduce this?
    val myList = listOf("A", "AA", "B", "BB")
    val aIndices = myList.mapIndexedNotNull { index, str -> if("A" in str) index else null } // 0 and 1
    y
    • 2
    • 7
  • c

    Colton Idle

    08/31/2021, 7:27 AM
    Any kotlin team members here? The kotlin project has a super nice changelog on every release. Any tips on how to avoid merge conflict hell with everyone updating changelog.md with their PRs?
    m
    e
    l
    • 4
    • 4
  • u

    umar

    08/31/2021, 6:25 PM
    Hello there! I'm looking for a coach to teach me Kotlin and work on real projects. I have basic knowledge on Kotlin, Java, Html, Css and Js.
    😂 1
    b
    • 2
    • 2
  • m

    Muhammad Zaryab Rafique

    09/02/2021, 10:45 AM
    Hi Devs, how can I implement Material You in android. Kindly guide me
    s
    • 2
    • 2
  • a

    avolkmann

    09/06/2021, 5:31 PM
    What are your thoughts on C# out variables? https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/out-parameter-modifier
    e
    t
    +4
    • 7
    • 11
  • m

    myanmarking

    09/09/2021, 10:29 AM
    is there any std fun on Lists, than when getting by index, if the index is greater than size, it will go back to zero? For instance, size: 3, get(4) will be the same as get(0)
    r
    t
    • 3
    • 6
  • h

    hho

    09/09/2021, 4:45 PM
    Weird problem: I can't create new projects anymore (IntelliJ IDEA 2021.2.2 RC). When I disable the Kotlin Plugin (212-1.5.30-release-409-IJ4638.7), it works again.
    • 1
    • 1
  • l

    louiscad

    09/10/2021, 9:58 AM
    What do you think this thing is?
    k
    y
    • 3
    • 9
  • c

    Chachako

    09/14/2021, 4:48 PM
    I’m curious. Is there a compiler plugin that supports automatic generation of
    equals
    ,
    hashcode
    ,
    toString
    ,
    copy
    , and others? Some things generated by
    data class
    are not what I want, and even it only generate properties in the primary constructor
    m
    • 2
    • 3
  • s

    Scott Kruse

    09/14/2021, 8:04 PM
    is there an extension function for confirming a lookup of an item in a list? e.g.
    list.firstOrNull { it is MySealedClass } != null
    r
    • 2
    • 2
  • r

    rtsketo

    09/15/2021, 6:50 AM
    Is it possible to create a placeholder function or template (or anything else) that will be replaced by the result of its code later on? We need a temporary conversion function, let's say
    fun f(x: Int) = x * 15 + 30
    so if we type
    f(10)
    in our code would be replaced with
    180
    later on (or even instantly). Not sure if it's ok to ask here, it seemed to me too random of a question to ask anywhere else. Edit: Even if it's possible somehow with the
    @Deprecated
    annotation, let me know.
    t
    l
    m
    • 4
    • 11
  • c

    Chachako

    09/16/2021, 6:51 AM
    Is there a way to let classes visible in multiple modules? The
    internal
    modifier is only visible in a single module, this is sometimes not in line with my expectations.
    e
    • 2
    • 4
  • s

    smit01

    09/17/2021, 8:00 AM
    Is there any noticeable difference between java17's sealed class and kotlin sealed class. ?
    p
    • 2
    • 1
  • n

    napperley

    09/17/2021, 10:33 PM
    Found an unprofessional code comment the other day in the EFL source code (was trying to figure out how to do the efl_ui_win_autodel_set function so it is accessible from the Kotlin side). Below is the code comment (part of the comment has been censored):
    /* FIXME: what the actual ****. */
    This comment is in the Efl_Ui.h file on line 184 (part of the libefl-all-dev v1.23.3-8 Debian Package).
    :lol: 1
    😄 1
    🙈 2
    😲 1
    f
    d
    • 3
    • 3
  • e

    elect

    09/19/2021, 5:46 PM
    Regex is still a pain for me, I need to match any whitespace outside double quotas, how can I match the first two here?
    t
    m
    • 3
    • 6
  • v

    Vadim Kuhay

    09/21/2021, 1:20 AM
    What is an appropriate channel to discuss and get tips for dealing with customers resisting adoption of Kotlin?
    n
    r
    m
    • 4
    • 4
  • s

    Scott Kruse

    09/21/2021, 6:19 AM
    has anyone tried Kotlin shell? for some reason im not seeing autocompletion, not sure if i need to do something to enable
    e
    n
    • 3
    • 7
  • v

    Vikas Singh

    09/22/2021, 7:16 PM
    Which are the best tools to generate document in kotlin ?
    n
    l
    m
    • 4
    • 4
  • f

    Fudge

    09/24/2021, 7:02 PM
    so... 1.6-M1 is out
    :kotlin-intensifies: 8
    💯 2
    n
    d
    • 3
    • 5
  • h

    Hullaballoonatic

    09/26/2021, 9:30 PM
    ngl, did not expect that...
    h
    f
    • 3
    • 9
  • m

    Marc Knaup

    09/27/2021, 7:53 PM
    https://genki.world Built with Kotlin/JS 😄 Had to write almost no JavaScript or TypeScript 🎉 🙏 Shared code between front-end and back-end. (We’re looking for a great Kotlin dev 👀)
    🤘 1
    :kotlin-intensifies: 2
    💯 5
    😍 2
    🎉 6
    :kotlin: 5
    m
    • 2
    • 8
  • c

    Cheenu Soni

    09/28/2021, 9:44 AM
    What is K2 compiler?
    c
    • 2
    • 1
  • a

    avolkmann

    09/29/2021, 7:05 AM
    Follow up to my previous question regarding
    out var
    in C#: What do you think about partial classes? They allow you to spread a class declaration over several files, which are merged together on build. Do you see any good applications for this? Could you imagine it in other languages?
    e
    j
    • 3
    • 2
  • t

    theapache64

    09/29/2021, 10:01 AM
    https://twitter.com/theapache64/status/1443146355262693377
    🆒 3
    🧙‍♂️ 2
    r
    • 2
    • 2
  • n

    Nikky

    09/29/2021, 10:36 AM
    i have this function:
    inline fun <reified T: FeatureSet> get(clazz: KClass<T> = T::class): T?
    when i call it like so
    val a: Any? = foo.get()
    i get the class
    FeatureSet
    which is abstract is there any way to forbid this syntax other than crashing at runtime ?
    :stackoverflow: 1
    r
    • 2
    • 5
  • j

    Jason5lee

    09/30/2021, 8:25 AM
    What is your favorite logging library or framework for Kotlin in backend? I see
    slf4j
    a lot in Java but I’m not sure if there is a better solution for Kotlin specific.
    ☝️ 1
    h
    r
    • 3
    • 2
  • m

    Marco Righini

    09/30/2021, 11:35 AM
    Hi everyone. Do you have some advices on courses/books related to: • Kotlin for iOS (Swift) developers • Kotlin Multiplatform for iOS developers Thanks!
    k
    • 2
    • 2
  • r

    rtsketo

    10/05/2021, 6:41 AM
    I'll name a variable that's from 0% to 100%,
    percent
    . How should a variable that's from 0 to 1 be called?
    m
    l
    +3
    • 6
    • 11
Powered by Linen
Title
r

rtsketo

10/05/2021, 6:41 AM
I'll name a variable that's from 0% to 100%,
percent
. How should a variable that's from 0 to 1 be called?
m

mzgreen

10/05/2021, 7:00 AM
fraction
?
👍 1
👍🏼 1
An example from Android APIs: https://developer.android.com/reference/android/animation/ValueAnimator#getAnimatedFraction()
l

louiscad

10/05/2021, 7:05 AM
xxxRatio
👍 3
👍🏼 1
k

Klitos Kyriacou

10/05/2021, 8:11 AM
I hope the variable is not called
percent
- it should be called
somethingPercent
or
percentSomething
depending on what that "something" represents. However,
percent
would be a good name for a
@JvmInline value class
.
l

louiscad

10/05/2021, 8:12 AM
Percentage
would be even better for a value class IMO.
➕ 3
m

Matteo Mirk

10/05/2021, 10:46 AM
Also “probability” has a value that ranges in [0,1]∈ℚ 😛
t

Tomasz Krakowiak

10/05/2021, 2:24 PM
Name that damn variable by name that represents it's freaking meaning, not by it type! : P
➕ 1
ex:
value class Fraction(
    /** Value in range [0,1] */
	val value : Double
)

val lookingForMyMeaning : Fraction
:yes-black: 2
And preferrably don't mix percentage [0,100] and fraction [0,1] in your API. Stick to fraction.
k

Klitos Kyriacou

10/05/2021, 2:43 PM
Yes, don't mix units. The Mars Orbiter disaster was caused by mixing metric and old units.
😂 1
☝️ 1
r

rtsketo

10/05/2021, 3:06 PM
That's why I prefer to have the types (units) in my variables' name. For example for custom Views in Android I use
dpWidth
and
pxWidth
. There are always the option of annotations or wrapper classes, but isn't that the easiest way? Same goes for the percentage (as it is a form of unit, %).
View count: 2