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

    adam-mcneilly

    01/17/2018, 2:55 AM
    Can it be done recursively? Can I somehow create a one liner fibonacci in Kotlin? 🤔
    g
    • 2
    • 3
  • a

    Ayden

    01/17/2018, 5:29 AM
    val
    is read only right?
    g
    • 2
    • 1
  • a

    Ayden

    01/17/2018, 6:14 AM
    Can I ask?
    g
    c
    +2
    • 5
    • 13
  • g

    gildor

    01/17/2018, 9:26 AM
    There are no properties in Java, so it’s impossible there. You can have private getter and public setter methods, but not properties. It’s popular feature request https://youtrack.jetbrains.com/issue/KT-14663
    a
    i
    • 3
    • 6
  • s

    sabag.ronen

    01/17/2018, 12:41 PM
    Abstract class VS interface with properties and default implementation which one is preferred by you and why?
    p
    s
    +4
    • 7
    • 8
  • j

    jw

    01/17/2018, 3:26 PM
    to trick the compiler in allowing you to craft and expression that's always
    false
    s
    • 2
    • 1
  • c

    Carl Hickman

    01/17/2018, 7:59 PM
    Any way to ‘fail’ the instantiation of a Kotlin class? I would like to fail instantiation in case certain constructor parameters are not valid.
    s
    l
    +3
    • 6
    • 7
  • j

    jhonsef

    01/17/2018, 8:02 PM
    Sorry, I dont speake English
    p
    • 2
    • 1
  • c

    ClaudiuB

    01/17/2018, 8:37 PM
    In my experience,
    as?
    or
    as
    doesn't seem to work when using them with generic
    T: KClass<out Any>
    . For example
    someClass as T
    will return
    someClass
    , even when
    T
    is not `someClass`'s ancestor. if anyone could put an eye on the code in the comment to this, that would be great! Currently, in trying to achieve
    instanceof
    -like behavior, my method returns
    true
    for
    Nothing::class instanceof Number::class
    and I wish I was joking 🤖 . I've been trying to figure this out for maybe 3 hours now?If I'm using generics properly, then
    as
    and
    as?
    are broken when used with generics?
    c
    k
    +2
    • 5
    • 58
  • l

    lex

    01/18/2018, 3:56 AM
    that is ok, spring boot bom v2.0.0.M7 contains that version
    g
    • 2
    • 2
  • v

    Vitaly

    01/18/2018, 9:49 AM
    Migrated Maven multi modules project to Kotlin and get problems with sub modules dependencies. Every submodule that use another submodule write error:
    Unresolved reference: moduleName
    Does anybody knows what can cause this problems?
    l
    • 2
    • 3
  • s

    stefanem

    01/18/2018, 12:52 PM
    I have questions regarding the new style guide. Is this the right channel?
    👋 1
    m
    • 2
    • 3
  • f

    fly2never

    01/18/2018, 1:05 PM
    A newbie question, in performance view, did kotlin coroutines perform like the iOS Grand Central Dispatch, in the same orders of magnitude?
    g
    • 2
    • 1
  • d

    diesieben07

    01/18/2018, 2:29 PM
    You can also replace
    player1.contains(it)
    with
    it in player1
    .
    👍 1
    s
    • 2
    • 2
  • c

    cedric

    01/18/2018, 6:39 PM
    Wonder why Gson is still using that
    Unsafe
    hack then
    c
    • 2
    • 1
  • j

    jw

    01/18/2018, 6:39 PM
    Gson is dead
  • o

    orangy

    01/18/2018, 6:59 PM
    Just 10 years, can it be that bad? :troll:
    s
    • 2
    • 1
  • o

    orangy

    01/18/2018, 7:08 PM
    @jw is there a blog post may be which describes these bad things about Gson? And how they are fixed in Moshi et al? I want to get educated and may be validate our serialization design against lessons learned?
    j
    • 2
    • 2
  • j

    jkbbwr

    01/18/2018, 7:36 PM
    https://github.com/fabienrenaud/java-json-benchmark
    j
    • 2
    • 2
  • t

    Timur Valiev

    01/19/2018, 3:43 AM
    Hi guys! Hello from China. I'm new to kotlin but I want to migrate small project from java to kotlin. Thing is that annotation base code geneation is used there. That code generator is written by me and it works ok with java sources and now I want to upgrade it a bit. I want it to be able to work both with java and kotlin source. What should I start with, maybe you can suggest me articles/examples to look for?
    l
    g
    • 3
    • 3
  • t

    Timur Valiev

    01/19/2018, 5:08 AM
    It seems that kapt is the entry point, am I right?
    t
    g
    • 3
    • 3
  • j

    jrtapsell

    01/19/2018, 11:38 AM
    Is there a way to get the
    Decompile
    button to change backtick names to make the java code valid?
    g
    • 2
    • 1
  • m

    marstran

    01/19/2018, 1:04 PM
    Outer::Inner
    worked for me.
    👍 1
    d
    • 2
    • 1
  • a

    Ansh

    01/19/2018, 1:07 PM
    I was going through Kotlin samples and tried this code.
    open class A {
    fun f() {
        print("A")
      }
    }
    
    interface B {
    fun f() {
    print("B")
    }
    }
    
    class C: A(),B {
    }
    Now, this code doesn't compile because class 'C' extends class 'A' and implements interface 'B' and both of them have functions 'f'. So, as soon as I override 'f' function in class 'C', it throws a compilation error that 'f' cannot be overridden because 'f' is not open in class A. Now a similar set up in Java would have worked easily.
    class A {
    final public void f() {
    System.out.println("A");
    }
    }
    
    interface B {
    default void f() {
    System.out.println("B");
    }
    }
    
    class C extends A implements B{
    }
    Wouldn't it be better if Kotlin also worked the same way as default method of Java interfaces work i.e pick up the default implementation only when no other implementation is available? And suppose if both class 'A' and interface 'B' are from a library, I won't be able to change the function 'f' to open. In that case it would be impossible for me to create the class 'C'. Does anybody here know what is the possible advantage of having this sort of implementation in Kotlin?
    m
    g
    • 3
    • 4
  • d

    diesieben07

    01/19/2018, 2:32 PM
    Iterable
    means "has an iterator". That means every
    Iterable
    can be used in the
    for
    -
    in
    loop, but something does not have to implement
    Iterable
    to be used in the
    for
    -
    in
    loop. All that is required to do so is an
    operator fun iterator(): Iterator
    .
    a
    • 2
    • 1
  • s

    Shawn

    01/19/2018, 2:54 PM
    If you’re not yet familiar with Kotlin iteration semantics, I strongly recommend going through the Conventions section of the Kotlin Koans
    👍 1
    a
    • 2
    • 8
  • j

    Joe

    01/19/2018, 3:16 PM
    @r4zzz4k I posted how I handle iterating in Kotlin.
    r
    • 2
    • 2
  • d

    dimsuz

    01/19/2018, 3:18 PM
    Interesting. Language doesn't allow
    inline + reified
    in interfaces, but I still can achieve virtually the same thing with extension functions:
    interface Store {
      inline fun <reified T> getValue(key: String): T // impossible, no go
    
      // so doing this
      fun <T> getValue(key: String, clazz: Class<T>): T // good
    }
    
    class StoreImpl : Store {
      override fun <T> getValue(key: String, clazz: Class<T>): T {
        // code
      }
    }
    
    inline fun <reified T> Store.getValue(key: String): T {
      return this.getValue(key, T::class.java)
    }
    
    fun main(args: Array<String>) {
      val i: Int = StoreImpl().getValue("hello")
    }
    a
    g
    • 3
    • 4
  • d

    diesieben07

    01/19/2018, 4:22 PM
    I have this type:
    List<@NotBlank String>
    . Is there a way to get the Kotlin compiler to properly generate type annotation metadata in a situation like this? Right now the
    @NotBlank
    annotation is not visible with the Java reflection API, even with
    javaParameters
    option set to
    true
    .
    g
    • 2
    • 2
  • c

    cy

    01/19/2018, 4:37 PM
    Support for Maven had always low priority
    👍 2
    👎 1
    p
    c
    s
    • 4
    • 41
Powered by Linen
Title
c

cy

01/19/2018, 4:37 PM
Support for Maven had always low priority
👍 2
👎 1
p

poohbar

01/19/2018, 4:37 PM
That's a terrible idea tbh.
Who unanimously decided that Gradle is the way to go? Have you ever had to maintain huge projects in Gradle? It's a major PITA.
c

cy

01/19/2018, 4:38 PM
Nobody particularly, just the world goes to Gradle
p

poohbar

01/19/2018, 4:39 PM
Just check the IntelliJ stats you collect about how many projects use Maven vs Gradle and you will find how wrong you are.
c

cy

01/19/2018, 4:40 PM
There is also delta: a lot of projects migrating to Gradle
p

poohbar

01/19/2018, 4:40 PM
Gradle with dying deprecated Groovy as a first class build-language and buggy Kotlin-build-language support. What a marvellous idea.
👎 2
c

cy

01/19/2018, 4:41 PM
And almost none migrating back from Gradle to Maven
c

Czar

01/19/2018, 4:41 PM
I sense a holywar brewing 😄
🍿 1
🔥 3
https://stackshare.io/stackups/gradle-vs-jitpack-vs-maven
p

poohbar

01/19/2018, 4:42 PM
I am not trying to start a flame war but I believe Maven should absolutely get as much support as Gradle does and anything else is a huge mistake and a huge middle finger to thousands of devs on Maven.
You could be opinionated about this if Kotlin's adoption was skyrocketing. But is it really?
It was so hard to convince my team to start using Kotlin and now you are trying to tell me we should switch to Gradle as well. That's not happening. So I might eventually be stuck with a project that does not even build!
c

cy

01/19/2018, 4:46 PM
There is nothing about actual advantages/disadvantages of Gradle, it's just about fashion, hype
today it's quite popular and it's popularity is growing, also it is almost the only build tool for Android
👍 1
p

poohbar

01/19/2018, 4:47 PM
Sure, but we can't just migrate the huge project to Gradle. You have to support both. God damn you support Java 1.6!
s

Shawn

01/19/2018, 4:48 PM
dude who pissed in your cheerios this morning
p

poohbar

01/19/2018, 4:48 PM
this guy ^
s

Shawn

01/19/2018, 4:48 PM
nobody’s saying anything about abandoning maven entirely
➕ 3
all sergey said was that maven support has been low priority, and for relatively sound reasons
p

poohbar

01/19/2018, 4:49 PM
lol sound reasons
giving into the hype and fashion is a sound reason..
s

Shawn

01/19/2018, 4:49 PM
JetBrains makes tools for other people
they’re not going to prescribe a build tool to the whole of the Android community
c

cy

01/19/2018, 4:49 PM
you known, incremental compilation support has been added to the maven plugin much much later
s

Shawn

01/19/2018, 4:50 PM
if the vast majority of the Android community uses gradle, JB’s not going to “give them the middle finger” and tell them they’re not going to prioritize gradle
👍 1
p

poohbar

01/19/2018, 4:50 PM
Wait I am not saying to prescribe anything. Both Maven and Gradle are widely used and I believe Maven is even more prevalent than Gradle. If not it might be around 1:1. So what's the reason to support one less? Makes no sense.
s

Shawn

01/19/2018, 4:51 PM
I’m going to hazard a guess and say Gradle is far more commonly used in both Android and Kotlin development overall.
You really only need to idle on this slack for a few days to tell most the build tool related questions are gradle ones
and if you’re gonna complain about other people mischaracterizing your arguments, maybe stop mischaracterizing other peoples
p

poohbar

01/19/2018, 4:51 PM
Yeah because Gradle is incomprehensible so people have to ask about everything.
s

Shawn

01/19/2018, 4:52 PM
Are you intentionally doing this?
c

cy

01/19/2018, 4:52 PM
so, finally the only we can do for now is to vote for the issue and wait
➕ 2
Also note that there are workarounds
p

poohbar

01/19/2018, 5:04 PM
Why would it work with 1.2.10 though?
c

cy

01/19/2018, 5:05 PM
Regression, probably caused by Java-Kotlin interop IC improvements
p

poohbar

01/19/2018, 5:08 PM
I guess experimental means truly experimental in this phase. As long as everything else works it's fine.
c

cy

01/19/2018, 5:09 PM
as I noted in the issue, you can simply add extra copy-resources execution after kotlin plugin to get resources back (compiler simply removes copied resources)
p

poohbar

01/19/2018, 5:10 PM
thanks
sound reasons: https://trends.google.com/trends/explore?date=all&amp;q=gradle,maven
s

Shawn

01/19/2018, 6:58 PM
ooh, I can make graphs too
https://trends.google.com/trends/explore?date=all&amp;q=gradle%20android,maven%20android
:gradle: 1
😂 1
View count: 2