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

    kevinmost

    08/15/2017, 6:40 PM
    you can't write a generic one of course since you can't have a function with a variable number of type params
    a
    1 reply · 2 participants
  • a

    agomez

    08/15/2017, 10:06 PM
    http://olivergierke.de/2013/11/why-field-injection-is-evil/
    t
    1 reply · 2 participants
  • j

    joshuaavalon

    08/16/2017, 8:59 AM
    I tired to use Dagger with Kotlin. I noticed that class are not generated. When I run Gradle in command line I get "'kapt.generate stubs' is not used by the 'kotlin-kapt' plugin". Anyone know why?
    g
    9 replies · 2 participants
  • d

    dragas

    08/16/2017, 10:02 AM
    is
    this::method
    actually leaking when called in
    init
    or
    constructor
    blocks?
    k
    2 replies · 2 participants
  • d

    diesieben07

    08/16/2017, 11:24 AM
    @michaelzinn You can also use the
    @JvmSuppressWildcards
    annotation like so:
    List<@JvmSuppressWildcards List<String>>
    .
    👍 1
    k
    m
    4 replies · 3 participants
  • r

    roberto.guerra

    08/16/2017, 1:34 PM
    Does
    kotlin-stdlib-jre8
    always include
    kotlin-stdlib-jre7
    , and if so, does it do any harm to use
    excludes
    to leave out
    jre7
    from the
    runtimeClasspath
    ?
    runtimeClasspath - Runtime classpath of source set 'main'.
    +--- org.slf4j:slf4j-api:1.7.22
    +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.4
    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4
    |    |    \--- org.jetbrains:annotations:13.0
    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.4
    |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4 (*)
    r
    r
    8 replies · 3 participants
  • r

    Ruckus

    08/16/2017, 8:51 PM
    @lab Something like this?
    val filtered = (0..list.lastIndex).asSequence()
        .filter { it in indexes }
        .map(list::get)
        .toList()
    (I haven't tested it)
    k
    3 replies · 2 participants
  • l

    lab

    08/16/2017, 9:18 PM
    @karelpeeters @Ruckus the purpose of the trie was for indexing and searching apps in an Android launcher. (The repo is at https://github.com/louisgv/janusLauncher) I'm refactoring the trie to return a
    List<AppModel>
    (AppModel store all necessary info of an Android app). Here's the
    getLeaves
    method that I'm testing around with:
    class WakeTrieNode (val key: Char?,
                        val value: AppModel?,
                        var isLeaf: Boolean,
                        val children: MutableMap<Char, WakeTrieNode> = mutableMapOf()) {
    
        fun getLeaves(): List<AppModel>{
            return if (isLeaf && value != null) listOf(value)
            else children.flatMap { child ->
                child.value.getLeaves()
            }
        }
    }
    Is there a better way to do this? The part where it return listOf(value) seems bad to me.
    k
    r
    14 replies · 3 participants
  • k

    karelpeeters

    08/16/2017, 9:45 PM
    contains
    checks for an exact match, so it doesn't really fit your use case.
    n
    l
    4 replies · 3 participants
  • p

    pniederw

    08/17/2017, 6:47 AM
    @joshuaavalon works for me, except for one known proguard bug which forces me to compile kotlin with target jvm-1.6
    j
    2 replies · 2 participants
  • t

    tschuchort

    08/17/2017, 11:39 AM
    is it possible to do something like
    abstract class A<T : S> : T
    where
    T
    is an interface?
    k
    1 reply · 2 participants
  • j

    jamieadkins95

    08/17/2017, 1:27 PM
    I’m getting a PROPERTY_WONT_BE_SERIALIZED warning when using the new Parcelize annotation.
    @Parcelize
    class ExampleClass : Parcelable {
    
        var id: Long? = 0
        var name: String? = null
        var tagName: String? = null
        var enabled: Boolean = false
    Do my properties have to be constructor parameters?
    l
    k
    13 replies · 3 participants
  • s

    santiago

    08/17/2017, 6:10 PM
    I’m getting an error that I can find no explanation for at all in the docs or on google generally: “Violation of Non-Expansive Inheritance Restriction for io.requery.query.LogicalCondition.” What is the Non-Expansive Inheritance Restriction?
    k
    t
    10 replies · 3 participants
  • s

    skennedy

    08/17/2017, 9:30 PM
    ugh i just got bit by the difference between
    val X = blah()
    and
    val X
      get() = blah()
    😐 2
    n
    t
    +1
    6 replies · 4 participants
  • a

    agrosner

    08/17/2017, 10:16 PM
    Maybe a warning from the kotlin plugin on vals defined as properties with expressions derived from functions would be nice
    k
    2 replies · 2 participants
  • h

    horse_badorties

    08/18/2017, 8:32 AM
    no, it doesn't. Nothing to do with vararg, it seems.
    fun foo(bool: Boolean = true, string1: String) {}
    fun main(args: Array<String>) {
       foo("b") // does not compile
    }
    k
    h
    13 replies · 3 participants
  • m

    mkatie

    08/18/2017, 10:55 AM
    Hi! We have an open call for papers for the MBLTdev Conference which takes place on October 27 in Moscow. We are searching for the Kotlin experts to deliver a talk and will be happy to award the best submission with a travel grant. Learn more here: https://goo.gl/forms/FE64ZDzvBSrc5OZP2
    o
    3 replies · 2 participants
  • m

    milorad

    08/18/2017, 11:04 AM
    Hi guys! Is there a way to use expressions with string interpolation? This looks horrible:
    it.Specification?.let {
                                    with(it) {
                                        val mk = (make ?: "")
                                        val md = model ?: ""
                                        "$mk $md"
                                    }
                                }
    k
    g
    5 replies · 3 participants
  • s

    silas.schwarz

    08/18/2017, 11:13 AM
    hi again, how do you guys/girls write tests for an infix function inside a builder
    m
    3 replies · 2 participants
  • k

    karelpeeters

    08/18/2017, 1:27 PM
    Or maybe you can run trough it with a debugger and check the exact classes of everything involved?
    t
    3 replies · 2 participants
  • e

    e.lislebo

    08/18/2017, 1:40 PM
    any recommendations for http request library with asynchronous requests? Is Fuel (https://github.com/kittinunf/Fuel) a good one?
    a
    o
    +2
    5 replies · 5 participants
  • n

    nickk

    08/18/2017, 1:51 PM
    Is there a function in the standard lib that could help in taking a list of doubles and consume 2 elements each time? I want to convert a flat list of lat-lon doubles to LatLng instances.
    k
    h
    +1
    7 replies · 4 participants
  • p

    Paul Woitaschek

    08/18/2017, 2:25 PM
    Is it a bug that reified inline functions are marked as private for java callers?
    k
    1 reply · 2 participants
  • b

    bloodshura

    08/18/2017, 7:29 PM
    Why I can't use Java's static getters and setters as properties (e.g.
    System.getProperties()
    ->
    System.properties
    )?
    k
    2 replies · 2 participants
  • b

    bamboo

    08/18/2017, 7:31 PM
    http://kotlinslackin.herokuapp.com/ is down
    k
    h
    3 replies · 3 participants
  • d

    dumptruckman

    08/19/2017, 2:39 AM
    Huh.. How do you do multiconditional for loops?
    d
    d
    +1
    3 replies · 4 participants
  • b

    billf

    08/19/2017, 11:09 PM
    Hi all. I ran into an interesting little problem with type inference producing a counter-intuitive result. It's not a bug, but it's maybe an example of an undesirable side-effect of the way things are specified right now.I was playing around with JKid, and writing a new unit test, and I had code like this:
    private val df = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz")
       private val value = TimeWithZone(df.parse("2017-08-18 17:25:26.632 PDT"))    
    
        @Test fun testDeserialization() {
           println("deserialize gives " +  deserialize(json))
           assertEquals(value, deserialize(json))
        }
    This failed with a ginormous stack backtrace, deep in the bowels of reflection, telling me it couldn't find a field of TimeWithZone. The fix is compact enough:
    println("deserialize gives " + deserialize<TimeWithZone>(json))
    OK, so in the assertEquals, type inference is used to make the call of deserialize<Any> into a call of deserialize<TimeWithZone>, whereas in a println, it's not. Reasonable enough, I guess, but a little non-obvious. Intuitively, I just don't expect an expression to change meaning based on where it's used. In this case, I'd actually rather that type inference hadn't made the assertEquals call work, and instead had forced me to type deserialize<TimeWithZone>(...) in the first place. I'm sure there's a case to be made for the more eager type inference that Kotlin has today, but I just thought I'd throw this out there as maybe an unintended and undesirable side-effect. I could see this behavior causing a lot of confusion, particularly for someone coming from a less statically-typed background.
    k
    3 replies · 2 participants
  • m

    marcinmoskala

    08/20/2017, 3:56 PM
    I have a problem with getting getter annotation from property reference. Here is annotation:
    class A {
        @get:Arg val a: Int by BoundToValueDelegateProvider()
    }
    Inside
    provideDelegate
    I have property reference
    operator fun provideDelegate(
            thisRef: Any?,
            prop: KProperty<*>
    ): ReadWriteProperty<Any, T> {
        val annotation1 = prop.getter.findAnnotation<Arg>() // This is null
        val annotation2 = prop.javaGetter?.getAnnotation(Arg::class.java) // This is null too
        // ...
    }
    It this bug or expected behavior?
    d
    2 replies · 2 participants
  • m

    muralimohan962

    08/20/2017, 4:11 PM
    When are coroutines going to be finalized?
    e
    1 reply · 2 participants
  • l

    ltm150895

    08/21/2017, 12:13 AM
    any ideas of how to not use the same data class to receive / send json like data ? , thanks in advance 🙂
    k
    3 replies · 2 participants
Powered by Linen
Title
l

ltm150895

08/21/2017, 12:13 AM
any ideas of how to not use the same data class to receive / send json like data ? , thanks in advance 🙂
k

karelpeeters

08/21/2017, 7:19 AM
Maybe I'm misunderstanding you problem, but the error message says the class within the annotation has to implement
TypeAdapter
or
TypeAdapterFactory
, while you're implementing
JsonDeserializer
. Just implement the correct one to fix the issue.
l

ltm150895

08/23/2017, 12:47 PM
I will try after work, thank you 👍
Funny thing, i updated the dependency "com.google.code.gson" to version = 2.8.1 and it works without any code changes
View count: 2