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

    Olekss

    12/22/2017, 7:44 AM
    The slow part is that declaredMemberProperties - takes a second - and there is only 4 props on my Class...
    c
    g
    • 3
    • 15
  • k

    karelpeeters

    12/22/2017, 7:53 AM
    Still strange, I can't really think of something that could cause it to take this long. It's not like your system is overloaded right? Or that something is taking up all disk reads?
    g
    c
    +3
    • 6
    • 15
  • c

    chb0kotlin

    12/22/2017, 5:58 PM
    Is there a more Kotlin idiomatic way of writing this class:
    class CompositeReader(private var readers: List<Reader> = listOf()) : Reader() {
        override fun close() = readers.forEach(Reader::close)
    
        override fun read(cbuf: CharArray?, off: Int, len: Int): Int {
            var result = -1
    
            if (readers.isNotEmpty()) {
                result = readers.first().read(cbuf, off, len)
                if (result == -1) {
                    readers = readers.subList(1, readers.lastIndex)
                    if (readers.isNotEmpty()) {
                        result = readers.first().read(cbuf, off, len)
                    }
                }
            }
            return result
        }
    
    
        fun copy(reader: Reader) = CompositeReader(readers = this.readers + reader)
    
    }
    s
    • 2
    • 1
  • k

    karelpeeters

    12/22/2017, 9:20 PM
    This is a common feture request: https://youtrack.jetbrains.com/issue/KT-14663
    r
    • 2
    • 1
  • s

    stkent

    12/23/2017, 3:55 AM
    When I call
    .withDefault
    on a map, the default behavior seems to be lost if I call another method (e.g.
    toMutableMap
    ) on that map instance. Is that expected/documented behavior? I couldn't find clear rules in the docs.
    k
    a
    • 3
    • 3
  • e

    evanchooly

    12/23/2017, 9:01 PM
    it’s likely complaining about the
    Y
    b
    s
    • 3
    • 3
  • j

    jsparn

    12/23/2017, 11:38 PM
    Ok. So what's up with this bit here
    var digitArray: MutableList<MutableList>
    k
    • 2
    • 1
  • j

    jkbbwr

    12/24/2017, 12:30 AM
    val converters = mutableMapOf<Class<*>, Load<*>>()
    d
    • 2
    • 1
  • k

    karelpeeters

    12/24/2017, 9:44 AM
    Comparator.naturalOrder<Message>()
  • f

    ferrytan

    12/24/2017, 5:31 PM
    i see... i guess i need to modify my code, thanks @Shawn!
    👍 1
    s
    • 2
    • 2
  • d

    dSebastien

    12/25/2017, 11:11 PM
    I was getting my sentence in the logical order first 😉
    k
    • 2
    • 2
  • d

    dSebastien

    12/26/2017, 12:17 AM
    Xebia got me answers, nice: https://blog.xebia.fr/2017/09/19/les-kproperty2-ou-la-reflexion-signee-kotlin/
    🇫🇷 1
    👍 1
    n
    • 2
    • 1
  • m

    mike_shysh

    12/26/2017, 9:19 AM
    Hi, how could affect application changing val to var in terms of memory usage?
    g
    • 2
    • 4
  • m

    mike_shysh

    12/26/2017, 3:55 PM
    Guys, Does anyone face the situation when jackson serialization partially wrong? For example:
    params={"currency_info":{"iso_4217":"CAD","name":"Canadian Dollar","imerchantAccount":0,"ixrateSource":2}}
    instead if
    params={"currency_info":{"iso_4217":"CAD","name":"Canadian Dollar","i_merchant_account":0,"i_xrate_source":2}}
    Here is the data class
    data class CurrencyInfo(
    		@JsonProperty("currency_info") val currencyInfo: CurrencyInfoItem?
    )
    
    @JsonInclude(JsonInclude.Include.NON_NULL)
    data class CurrencyInfoItem(
    		@JsonProperty("iso_4217") val iso4217: String?,
    		@JsonProperty("name") val name: String?,
    		@JsonProperty("name_major") val nameMajor: String?,
    		@JsonProperty("name_minor") val nameMinor: String?,
    		@JsonProperty("i_ma_currency") val iMaCurrency: Int?,
    		@JsonProperty("i_merchant_account") val iMerchantAccount: Int?,
    		@JsonProperty("i_x_rate_source") val iXRateSource: Int?,
    		@JsonProperty("base_units") val baseUnits: Double?,
    		@JsonProperty("min_allowed_payment") val minAllowedPayment: Int?,
    		@JsonProperty("decimal_digits") val decimalDigits: Int?,
    		@JsonProperty("is_used") val isUsed: Boolean?
    )
  • k

    karelpeeters

    12/26/2017, 4:18 PM
    buildSequence(::getThingBlocking).forEach { ... }
    z
    • 2
    • 11
  • l

    lewik

    12/26/2017, 7:43 PM
    Did anybody faces
    An exception occurs during Evaluate Expression Action : Back-end (JVM) Internal error: No implClassName for public expect fun kotlin.Array<out kotlin.Byte>.toByteArray(): kotlin.ByteArray defined in kotlin.collections[DeserializedSimpleFunctionDescriptor...
    exception? In
    public expect fun Array<out Byte>.toByteArray(): ByteArray
    called on Byte[] size 78
    a
    • 2
    • 2
  • g

    groostav

    12/27/2017, 7:01 AM
    well this is pretty frustraiting. The only thing I could find to do was go into
    C:\Users\Geoff\.IntelliJIdea2017.3\config\plugins\Kotlin
    deleting files and copying them over from the zip for 1.1.60 downloaded on the archives https://plugins.jetbrains.com/plugin/6954-kotlin
    k
    • 2
    • 13
  • e

    Erfan

    12/27/2017, 2:57 PM
    why is it so?
    g
    • 2
    • 5
  • i

    irus

    12/27/2017, 3:07 PM
    Huh, so I have to use hack:
    inline fun <reified T : Any?> sample() {
        println("Is nullable: ${isNullable<T>()}")
    }
    
    inline fun <reified T : Any?> isNullable(): Boolean {
        return try {
            null as T
            true
        } catch (e: Exception) {
            false
        }
    }
    
    fun main(args: Array<String>) {
        sample<String?>()
        sample<String>()
    }
    s
    • 2
    • 2
  • h

    herlevsen

    12/27/2017, 4:42 PM
    Alright. If i use a secondary constructor i have to provide defaults for the non-nullable fields, which feels wrong to me. And the init block is just extra boilerplate, that i would rather not type. Would be cool if there was some way to explicitly call the setter from the primary constructor
    k
    • 2
    • 9
  • m

    mike_shysh

    12/27/2017, 5:34 PM
    dataIds.put(cc.customerClassInfo?.name, ccResponse.iCustomerClass)
  • q

    qwert_ukg

    12/28/2017, 7:19 AM
    Which modifier should be used for declaring for using inside package only?
    g
    • 2
    • 1
  • a

    altmind

    12/28/2017, 11:57 AM
    this gives me "Smart cast not possible: t is a mutable property that can change over time"
    a
    • 2
    • 1
  • m

    mike_shysh

    12/28/2017, 12:15 PM
    Hi, please help me with this strange behaviour) I use testNG, and my lateinit variable is not initialized in @ BeforeSuit
    open class BaseTest {
        lateinit var testDataConst: MutableMap<String?,Int?>
    
        @BeforeSuite
        fun setup() {
            testDataConst = prepareBaseData(conf[system.user],conf[system.password])
            println(testDataConst) <<< here testDataConst is initialized
        }
    But in Test class testDataConst is uninitialized
    class AddCustomer : BaseTest() {
        @ Test
        fun addCustomer() {
            println(testDataConst)  <<< Here it is an error
        }
    }
    How could I solve it?
    a
    c
    • 3
    • 22
  • r

    rkeazor

    12/28/2017, 5:39 PM
    well if you work on a codebase thats both java and kotlin , you will eventually run into this !! , 7 times out of 10
    j
    • 2
    • 1
  • b

    bod

    12/28/2017, 6:00 PM
    you should know better than the compiler 🙂
    😂 1
    j
    k
    +4
    • 7
    • 15
  • g

    groostav

    12/29/2017, 2:00 AM
    I'd really really like to know (because that application architecture is increasingly looking better to us)
    k
    • 2
    • 2
  • n

    nil2l

    12/29/2017, 10:15 AM
    I got this exception:
    kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Introspecting local functions, lambdas, anonymous functions and local variables is not yet fully supported in Kotlin reflection
    In function
    toString()
    of a data class. The data class contains a lambda. Do I need to override
    toString()
    to exclude the lambda? Or lambdas are not allowed in data classes at all?
    :stackoverflow: 1
    v
    • 2
    • 2
  • r

    Roberto Fernandez

    12/29/2017, 12:44 PM
    hi guys, i have a simple question, i’ve overrided a class that exposes a method
    protected Class getPrototypeClass(T content) {
    With this code
    override fun getPrototypeClass(content: AlfredElement): Class<*> {
            return when (content) {
                is Category -> AlfredCategoryRenderer::class.java
                is Suggestion -> AlfredSuggestionElement::class.java
            }
        }
    And AlfredCategoryRenderer is a class with this type
    : Renderer<AlfredElement>()
    So, how can i tell kotlin compiler something like i can do i java which is tell the method getPrototypeClass will return a class that is Something like extends AlfredElement?
    v
    m
    • 3
    • 3
  • a

    Andreas Sinz

    12/29/2017, 1:17 PM
    @Roberto Fernandez how do you tell java that?
    :thread-please: 1
    m
    r
    • 3
    • 5
Powered by Linen
Title
a

Andreas Sinz

12/29/2017, 1:17 PM
@Roberto Fernandez how do you tell java that?
:thread-please: 1
m

marcinmoskala

12/29/2017, 2:03 PM
Check my answer above. In think that the answer to your question is
Class<? extends Renderer>
a

Andreas Sinz

12/29/2017, 2:35 PM
i'm just wondering what exactly he is trying to achieve
r

Roberto Fernandez

12/29/2017, 3:07 PM
Class<? extends Whatever>
exactly would be Class<? extends AlfredElement>
I’m not sure because is not code that is java and it’s being moved to kotlin, so i guess that code should work in java, but not sure about
View count: 2