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

    adeln

    03/09/2017, 1:33 PM
    but I don’t think it will come from a language, the main point of which is to fix Java but who knows 🙂
    m
    e
    +3
    • 6
    • 57
  • y

    yole

    03/09/2017, 4:47 PM
    ?
    doesn't exist by itself
    d
    • 2
    • 2
  • m

    marcinmoskala

    03/11/2017, 8:32 PM
    It is really big indent
    m
    • 2
    • 2
  • m

    marcinmoskala

    03/15/2017, 12:06 PM
    is it ok?
    m
    • 2
    • 4
  • m

    mg6maciej

    03/15/2017, 12:11 PM
    I may have created a few impure properties in the past, but it might be a good default recommendation not to do that.
    e
    m
    • 3
    • 7
  • v

    voddan

    03/22/2017, 12:32 PM
    Note that you can have multiple init blocks
    😮 2
    e
    d
    • 3
    • 4
  • c

    codeslubber

    03/26/2017, 3:14 PM
    apparently Go can also recompile unit tests in seconds, one of the worst if not the worst shortcomings of VM languages.. it’s insane how much focus has been given to shortening the amount of typing that developers have to do, when compile times for a simple test rerun vary by orders of magnitude...
    👍 1
    v
    • 2
    • 2
  • c

    codeslubber

    03/26/2017, 4:43 PM
    but compilation still took a while
    m
    • 2
    • 5
  • m

    mg6maciej

    04/01/2017, 4:18 PM
    @redrield Why did you tell her to get out? That wasn't nice.
    t
    • 2
    • 1
  • m

    mg6maciej

    04/01/2017, 9:10 PM
    I guess I'm somewhere in the middle. I would want this useless-to-compiler information not to be encoded in the model we are using to store code and let each and every user define their own view with their own preference. So Marketa could use tabs, 2 spaces width and you could use 4 spaces.
    👍 1
    t
    f
    v
    • 4
    • 9
  • c

    cedric

    04/02/2017, 5:18 AM
    One of the main reasons why I dislike ASCII art in the code (such as aligning on the parameters above) is that if I decide to rename the function name and change its length, then the whole parameter list is going to appear as a diff, while it's not really a diff
    👍 8
    m
    • 2
    • 1
  • b

    bachhuberdesign

    04/08/2017, 5:26 PM
    Quick question.
    lateinit private var
    or
    private lateinit var
    ?
    1️⃣ 1
    2️⃣ 17
    k
    • 2
    • 2
  • b

    bamdmux

    04/27/2017, 5:26 AM
    For example if you have
    MyClass.()-> Unit
    have a typealias
    MyClassExtension
    or if you have
    Generic<T>
    typealiases would be
    IntGeneric
    or
    StringGeneric
    l
    • 2
    • 2
  • m

    miha-x64

    05/04/2017, 8:01 AM
    Wow, you’ve created a new channel 🙂
    m
    • 2
    • 1
  • y

    yole

    05/24/2017, 5:53 PM
    I'm now working on a full style guide for Kotlin based on notes at https://github.com/yole/kotlin-style-guide/issues, and I'd appreciate your feedback. here's the current draft: https://github.com/JetBrains/kotlin-web-site/blob/e562c56615b4ba6c51a8b2251eb3e201860b15e4/pages/docs/reference/coding-conventions.md
    👍 1
    f
    m
    • 3
    • 4
  • m

    mg6maciej

    05/24/2017, 5:55 PM
    @yole camel humps with an uppercase first letter = PascalCase 😉
    👍 1
    f
    • 2
    • 1
  • k

    kirillrakhman

    05/24/2017, 6:05 PM
    Avoid using multiple labeled returns in a lambda. Consider restructuring the lambda so that it will have a single exit point. If that's not possible or not clear enough, convert the lambda into an anonymous function.
    if the lambda doesn't close over any locals, why not a proper method?
    y
    • 2
    • 3
  • m

    mg6maciej

    05/24/2017, 6:22 PM
    If default formatter is changed to that and you try to do in on Kotlin codebase itself, you would get tens of thousands of lines changed.
    y
    • 2
    • 2
  • k

    kevinmost

    05/24/2017, 8:25 PM
    1️⃣ might look weird in your Slack snippet, but with IDE highlighting I don't think you're frequently going to get mixed up looking at it. I don't know about others, but I also like to put an empty line after my class header, usually
    y
    • 2
    • 1
  • k

    kevinmost

    05/25/2017, 6:02 PM
    anyone have a particularly clean way to ensure that a
    when
    whose result you don't care about is exhaustive? I could store it into a variable (and explicitly suppress the unused lint warning), or chain an empty, unused
    .run {}
    on it, presumably. Anyone have any less weird ways?
    k
    • 2
    • 3
  • y

    yole

    05/26/2017, 2:58 PM
    Second draft of the style guide, feedback still welcome: https://github.com/JetBrains/kotlin-web-site/blob/636fe9e9d799eaa1e5c9d02b838f45aab1a13af2/pages/docs/reference/coding-conventions.md
    d
    • 2
    • 2
  • r

    reggar

    05/26/2017, 3:49 PM
    Perhaps its in the doc and I’ve missed it but I’d like to see a rule around uses of curly brackets (https://github.com/yole/kotlin-style-guide/issues/20). My personal preference is cypressious’s suggestion.
    y
    • 2
    • 1
  • c

    cedric

    05/26/2017, 3:52 PM
    What's that suggestion?
    r
    • 2
    • 1
  • k

    kevinmost

    05/26/2017, 8:37 PM
    I usually place it at the start, probably just a holdover from
    static
    stuff usually going at the top in Java though Where does everyone usually put it? ⬆️ or ⬇️
    ⬇️ 13
    ⬆️ 7
    b
    • 2
    • 1
  • m

    mg6maciej

    05/27/2017, 7:25 PM
    I like to put private functions next to their use. But it gets pretty hard to do that in 1-dimentional space which is file.
    🤔 2
    t
    • 2
    • 4
  • e

    elect

    06/02/2017, 7:56 AM
    is there a way to have a variable assignment with
    if - else
    with the code indented based on the position of the
    if
    ?
    val list = if(student != null && student.passing)
                  getListForStudent(student)
               else 
                  getStandardList()
    m
    c
    • 3
    • 4
  • f

    feniix

    06/12/2017, 11:06 PM
    fun get_currency_value(currency: String): String {
        val r = khttp.get("<https://api.coinbase.com/v2/exchange-rates?currency=$currency>")
        when (r.statusCode) {
            200 -> return r.jsonObject.getJSONObject("data").getJSONObject("rates").getString("USD")
            else -> return ""
        }
    }
    r
    j
    • 3
    • 18
  • m

    mg6maciej

    06/14/2017, 12:55 PM
    I usually put a single public (extension) function per file and name it the same as function except PascalCase, e.g.
    fun assertAll
    would go into
    AssertAll.kt
    .
    k
    • 2
    • 2
  • k

    kevmoturi

    07/06/2017, 2:34 PM
    Where should companion objects go in the file? Top or the bottom? Also coming from java... how are we supposed to treat files? should i just keep all related classes in one file?
    b
    z
    • 3
    • 6
  • b

    bachhuberdesign

    07/10/2017, 3:11 PM
    Makes sense, I almost wish there was a parameter folding feature so that you could fold to _ for unused parameters in the IDE but keep explicit naming in the actual code… but that’s way beyond scope
    v
    • 2
    • 1
Powered by Linen
Title
b

bachhuberdesign

07/10/2017, 3:11 PM
Makes sense, I almost wish there was a parameter folding feature so that you could fold to _ for unused parameters in the IDE but keep explicit naming in the actual code… but that’s way beyond scope
v

voddan

07/11/2017, 8:47 AM
If you think this would be a good idea, you are always welcome to submit a feature request to the kotlin team
View count: 3