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

    alchzh

    11/20/2017, 1:56 AM
    Can someone review my code? Just started learning Kotlin this morning, so decided to port over some existing code... https://github.com/acz13/anagrams/tree/kotlin-rough/kotlin
    d
    1 reply · 2 participants
  • t

    trent

    11/20/2017, 5:18 AM
    How to release reference explicitly for garbage collection / memory leak prevention purposes, like
    context = null
    , for Non-Nullable types? Is it impossible?
    k
    2 replies · 2 participants
  • t

    tekjar

    11/20/2017, 11:31 AM
    Hi. Is there a way to iterate all the components of a data class?
    s
    s
    +1
    6 replies · 4 participants
  • t

    techie01

    11/20/2017, 11:36 AM
    how to declare mutable map inside mutable map
    m
    1 reply · 2 participants
  • c

    carolos

    11/20/2017, 1:28 PM
    hi there I am trying to use the gradle kotlin dsl and define properties in the following way:
    var kotlin_version by extra { "1.1.60" }
    and I am getting an unresolved reference 😞 even though I have seen some examples that do that instead I have to do this:
    var kotlin_version: String by extra
    kotlin_version = "1.1.60"
    am I doing something wrong?
    m
    1 reply · 2 participants
  • h

    Hugh

    11/21/2017, 12:43 PM
    Hi all, I'm new to Kotlin, is there any way to execute code during construction of a data class, I want to call a function on the value as it's being passed into the constructor
    k
    h
    3 replies · 3 participants
  • c

    chi

    11/22/2017, 11:48 AM
    Hey guys, I'm having an issue for the following snippets. One crashes, the other doesn't crash.
    val bufferedImgFile: BufferedImage = ImageIO.read(File(filePath))
    val imageMatrix: Array<IntArray> = Array(height) { IntArray(width) }
    (0..(bufferedImgFile.height - 1)).map { hgt ->
            (0..(bufferedImgFile.width - 1)).map { wdt ->
              imageMatrix[hgt][wdt] = bufferedImgFile.getRGB(hgt, wdt)
            }
          }
    And
    val bufferedImgFile: BufferedImage = ImageIO.read(File(filePath))
    val imageMatrix: Array<IntArray> = Array(height) { IntArray(width) }
    async {
            (0..(bufferedImgFile.height - 1)).map { hgt ->
              async {
                (0..(bufferedImgFile.width - 1)).map { wdt ->
                  data[hgt][wdt]= bufferedImgFile.getRGB(hgt, wdt)
                }
              }
            }
          }
    The former would crash with an
    ArrayOutOfBoundsException
    , the later doesn't crash and completes. Please why is this so?
    a
    p
    9 replies · 3 participants
  • t

    tekjar

    11/22/2017, 11:56 AM
    Hi.
    shr
    is not resolved in the above function
    c
    a
    6 replies · 3 participants
  • o

    Oleksii Malovanyi

    11/22/2017, 3:40 PM
    Hello, I’m playing around with
    detekt
    and wanna write custom rules for android (e.g. ignore UnsafeCast for
    context.getSystemService
    ), so a bit messy with AST and
    compiler-embedable
    module. Could anyone provide link to some tutorial or smth to understand basics of
    ASTNode
    parsing: e.g. how to get method body properly or get variable type, etc. Thanks!
    s
    2 replies · 2 participants
  • s

    Snild

    11/23/2017, 11:25 AM
    error()
    looks good. But we're all in agreement that this is a bit weird, right? Would it be reasonable to file an issue on the compiler, to get some kind of official opinion on whether or not it works as intended?
    e
    k
    7 replies · 3 participants
  • k

    kristofdho

    11/23/2017, 12:45 PM
    str
    is an implicitly predefined variable
    s
    4 replies · 2 participants
  • t

    tulio

    11/23/2017, 2:18 PM
    Hi folks, I was wondering… What’s the real disadvantages of using inline functions in Kotlin?
    h
    d
    +3
    6 replies · 6 participants
  • d

    Dias Neto, J.

    11/24/2017, 3:12 AM
    why !! operator exists? Why is it needed? Is there some really good reason?
    r
    r
    4 replies · 3 participants
  • v

    vxh.viet

    11/24/2017, 4:04 AM
    Hi guys, I'm a newcomer to kotlin and I've been working through the Kotlin in Action book. I'm currently on chapter 6.3.5 and I don't quite get this snippet:
    >>> val letters = Array(26) { i -> ('a' + i).toString() }
    >>> println(letters.joinToString(""))
    abcdefghijklmnopqrstuvwxyz
    What exactly is
    'a' + i
    ? I've done a little bit of testing and depending on
    i
    it will return a character. For example:
    println('a' + 2) 
    c
    It seems very basic but I can't find any more detail explanation for this.
    r
    5 replies · 2 participants
  • b

    birgersp

    11/24/2017, 2:13 PM
    What would you suggest I do for testing my code, then?
    i
    1 reply · 2 participants
  • s

    Slackbot

    11/24/2017, 2:28 PM
    This message was deleted.
    t
    v
    2 replies · 3 participants
  • t

    tmseiler

    11/24/2017, 9:03 PM
    what's the most straight-forward way to do unit tests with kotlin (non-android standalone app)? preferably with a low dependency footprint. I tried doing spek and following its guides, but after installing a bunch of things including the idea plugin, it's still not running properly w/ idea
    j
    s
    5 replies · 3 participants
  • e

    elect

    11/25/2017, 6:58 PM
    can I directly remove an element from
    data.requests
    with
    map
    instead of using the
    if
    at the end?
    val rq = data.requests.find{ it.id == which && it.loaded }
            if(rq != null){
                val sc = rq.scene
                if (--rq.refCnt == 0)  data.requests.remove(rq)
                return sc
            }
    p
    2 replies · 2 participants
  • s

    Slackbot

    11/28/2017, 8:48 AM
    This message was deleted.
    a
    f
    2 replies · 3 participants
  • t

    tekjar

    11/28/2017, 10:01 AM
    Ohhh..So there is one companion object for all the class objects
    k
    1 reply · 2 participants
  • a

    alex.tavella

    11/28/2017, 3:22 PM
    use whateverLabel@ just before bracket
    w
    1 reply · 2 participants
  • p

    poohbar

    11/29/2017, 1:18 PM
    I am not an expert on generics and I like that we can reify generics in case of inline functions. Why can't Kotlin reify all other generics as well though? Just fake it by passing an extra parameter of type Class to any generic method?
    d
    2 replies · 2 participants
  • s

    Smit Aen

    11/29/2017, 2:08 PM
    Hi friends, I am learning Android and I also want to learn kotlin at the same time... Till now I have not worked on a single line of code in kotlin... Plz suggest me how to start code in kotlin..
    k
    1 reply · 2 participants
  • b

    birgersp

    11/29/2017, 2:18 PM
    Can Kotlin implement the same interface (with different generic types) multiple times? After some experiments, I guess not. If that's true, how can I work around it?
    k
    4 replies · 2 participants
  • a

    adam-mcneilly

    11/29/2017, 2:55 PM
    Found it - https://antonioleiva.com/sealed-classes-kotlin/
    👍 2
    h
    a
    6 replies · 3 participants
  • k

    kevinmost

    11/29/2017, 7:45 PM
    Kotlin doesn't use
    void
    or
    Void
    , it uses
    Unit
    . You want
    logic: (g: Graphics) -> Unit
    j
    s
    +1
    18 replies · 4 participants
  • b

    birgersp

    11/30/2017, 8:28 AM
    Hi. How can I pass a member function as an argument to a function that accepts a interface? Here's my attempts:
    interface Consumer<T> {
    
        fun consume(item: T)
    }
    
    class SomeClass {
    
        fun processInteger(integer: Int) {
    
            println("I got ${integer}")
        }
    }
    
    fun invokeConsumerFunction(consumer: Consumer<Int>) {
    
        consumer.consume(123)
    }
    
    fun main(args: Array<String>) {
    
        val obj = SomeClass()
    
        // Attempts, neither of them compiles
        invokeConsumerFunction(obj.processInteger)
        invokeConsumerFunction({item -> obj.processInteger(item)})
    }
    p
    a
    14 replies · 3 participants
  • l

    leodeng

    11/30/2017, 7:46 PM
    this raw string syntax is a rare thing from kotlin that i don’t quite like - it looks tediously long. i’d much prefer the typescript backtick syntax, but unfortunately the backtick was already taken for escaping identifiers using keywords
    a
    1 reply · 2 participants
  • k

    karelpeeters

    12/01/2017, 2:57 PM
    Java has it I think in
    java.lang.Character
    , not sure though.
    a
    1 reply · 2 participants
  • a

    Andreas Sinz

    12/01/2017, 3:29 PM
    @adam-mcneilly create an issue (http://kotl.in/issue) about that missing extension method
    👍 1
    :youtrack: 1
    a
    1 reply · 2 participants
Powered by Linen
Title
a

Andreas Sinz

12/01/2017, 3:29 PM
@adam-mcneilly create an issue (http://kotl.in/issue) about that missing extension method
👍 1
:youtrack: 1
a

adam-mcneilly

12/01/2017, 3:46 PM
https://youtrack.jetbrains.com/issue/KT-21569
View count: 1