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
announcements
  • t

    tipsy

    05/02/2018, 2:14 PM
    i'm trying to make a generic json-mapper plugin:
    @FunctionalInterface
    interface JsonToObjectMapper {
        fun <T> map(json: String, targetClass: Class<T>): T
    }
    
    var jsonToObjectMapper = object : JsonToObjectMapper { // use lambda here somehow?
        override fun <T> map(json: String, targetClass: Class<T>): T {
        }
    }
    according to this SO post (https://stackoverflow.com/questions/22588518/lambda-expression-and-generic-method/22588738#22588738) you can't combine generics and lambdas in java, but is it possible to achieve in kotlin somehow?
    c
    • 2
    • 3
  • a

    adam-mcneilly

    05/02/2018, 2:34 PM
    hmm but that is internal right so I can't reference it.
    Error:(6, 6) Cannot access 'OnlyInputTypes': it is internal in 'kotlin.internal'
    k
    • 2
    • 6
  • s

    Slackbot

    05/02/2018, 2:54 PM
    This message was deleted.
    🤣 1
    🚯 4
    👎 19
    🚓 8
    p
    k
    +3
    • 6
    • 7
  • m

    marcinmoskala

    05/02/2018, 6:01 PM
    I read book about category theory
    m
    • 2
    • 5
  • r

    robstoll

    05/02/2018, 6:07 PM
    fun <T> foo(t: T){
        val i: (T) -> T = { it }
    }
    m
    • 2
    • 31
  • b

    benleggiero

    05/03/2018, 2:57 AM
    I wish I could do this in Kotlin…

    https://i.imgur.com/fDwYP3f.png▾

    r
    i
    c
    • 4
    • 4
  • v

    v79

    05/03/2018, 8:46 AM
    Does kotlin have an equivalence of the C++ static member field? It can be done in Java, but I can't think how I'd do it in kotlin. https://www.geeksforgeeks.org/static-keyword-in-java/
    d
    • 2
    • 2
  • d

    droidrcc

    05/03/2018, 9:33 AM
    but what should be the key type for the map ?
    n
    • 2
    • 3
  • u

    ubu

    05/03/2018, 6:50 PM
    https://gist.github.com/uburoiubu/6ef31c56573a74fe4e4c5709936c1d06 could you explain to me why it does not work? I’m trying to write a regex in Kotlin that would match input like this:`{{something}}`. any help would be appreciated.
    i
    • 2
    • 3
  • m

    Marharyta Nedzelska

    05/03/2018, 7:43 PM
    Hi! Had anyone ever tried to use Scala interop in Kotlin (like using scala classes, implementing interfaces, scala collections etc)? I know sounds ugly, but… 🙂
    o
    t
    +2
    • 5
    • 9
  • a

    adams2

    05/03/2018, 8:13 PM
    how do you mock extension methods
    i
    g
    • 3
    • 2
  • a

    adams2

    05/03/2018, 8:17 PM
    ok say I have file manipulation code I would like to test, like "what should my code do when File.deleteRecursively returns false"
    g
    • 2
    • 1
  • j

    jw

    05/03/2018, 8:21 PM
    i have a lot of thoughts here around testing that are unrelated to the problem you are trying to solve so i'm going to try really hard to avoid launching into them. when i've had to do this in the past for
    RandomAccessFile
    I have subclassed it and returned
    false
    from
    delete()
    o
    • 2
    • 1
  • o

    orangy

    05/03/2018, 8:23 PM
    If you structure you code into small functions:
    fun fileManipulationCode(file: File) {
       when (file.deleteRecursively()) {
          true -> reportSuccess()
          false -> doSomethingElse()
       }
    }
    then you can test
    doSomethingElse
    separately.
    🤔 1
    s
    r
    • 3
    • 3
  • s

    Slackbot

    05/03/2018, 10:07 PM
    This message was deleted.
    s
    c
    • 3
    • 3
  • c

    cprigent

    05/04/2018, 12:59 PM
    thank you, it only for local or dev env
    g
    • 2
    • 1
  • r

    robstoll

    05/04/2018, 2:02 PM
    does kotlin have a way to turn a function into one which is evaluated only once? Something like
    fun <R> (() -> R).evalOnce(): () -> R {
        val v by lazy { this() }
        return { v }
    }
    but which works also for functions with one or more parameters?
    p
    j
    +2
    • 5
    • 7
  • d

    diesieben07

    05/04/2018, 2:12 PM
    There is no `return`ing from lambdas
    s
    r
    h
    • 4
    • 17
  • j

    Joeywp

    05/04/2018, 7:22 PM
    Does anyone know how to configure IntelliJ Idea with Kotlin external annotations? If I use an external @Deprecated annotation the IDE picks it up correctly, but when I annotate it with @Nullable (from org.jetbrains.annotations.Nullable) the IDE just ignores it's nullability? Edit: It's for an external library, that's why I have to use the external annotations
    s
    • 2
    • 17
  • r

    robstoll

    05/05/2018, 10:17 AM
    What is the reason that there is only a spread operator for
    Array
    but not for `Collection`/`Iterable`?
    j
    k
    • 3
    • 8
  • t

    tipsy

    05/06/2018, 4:56 PM
    i have a setter method:
    fromJson(JsonToObjectMapper jsonToObjectMapper)
    (java), which configures how my library does json-mapping:
    public interface JsonToObjectMapper {
        <T> T map(String json, Class<T> targetClass);
    }
    calling this method works fine from java, but kotlin is unable to infer types. if i try to to:
    val gson = GsonBuilder().create()
    myPlugin.fromJson(gson::fromJson)
    i just get
    None of the following functions can be called with the arguments supplied.
    any ideas?
    a
    • 2
    • 16
  • d

    diesieben07

    05/07/2018, 9:14 AM
    Either
    list.associate { key to value }
    or
    list.associateBy { key }
    👍 1
    e
    • 2
    • 6
  • s

    selckin

    05/07/2018, 9:22 AM
    i'd strongly recommend cxf
    ➕ 1
    j
    • 2
    • 3
  • e

    Erfan

    05/07/2018, 1:00 PM
    hi, how to create an empty generic array in Kotlin?
    var items: Array<T> = ?
    I wanted to use
    arrayOf<T>()
    but this doesn't work.
    a
    r
    +2
    • 5
    • 22
  • o

    osamarao

    05/07/2018, 6:15 PM
    I've been working on an code generation annotation processor in kotlin. The generated code is saved in whatever
    kapt.kotlin.generated
    is pointing to. In my case its in
    /generated/source/kaptKotlin/
    When you want to access the generated functions, android cannot find them unless you add to your build.gradle
    android {
    …
    sourceSets {
    main {
    java {
         srcDir "${buildDir.absolutePath}/generated/source/kaptKotlin/"
    }
               		}
       	}
    }
    is there a way to avoid this?
    • 1
    • 2
  • j

    jdemeulenaere

    05/07/2018, 6:16 PM
    Has anyone here developed a Kotlin compiler plugin ? I’d like to generate multiplatform Kotlin code and I think it’s the only solution 😕
    c
    • 2
    • 1
  • c

    Czar

    05/07/2018, 9:44 PM
    tablets nowadays are much more powerful than the PC I had when I first installed IJ CE and wrote something in Java 1.5 🙂
    s
    x
    s
    • 4
    • 6
  • j

    JoeHegarty

    05/07/2018, 11:28 PM
    Hey folks. I've been using Kotlin for a while and overall I'm sold on the language. I'm currently heading up a review with a view to moving a pretty large team (30+) of devs from Java to Kotlin. Obviously such a move isn't a straight port but would be maintaining existing Java code alongside new code in Kotlin. I'm interested in any experiences other teams have had doing this kind of migration. I'm particularly interested in any challenges around ramping up a new team, compatibility with existing tools (build/code quality/coverage/review) and benefits/drawbacks of large mixed Java/Kotlin projects. So if anyone has any experiences themselves or can point me to some writeups that would be great.
    c
    i
    • 3
    • 15
  • c

    cfleming

    05/08/2018, 12:25 AM
    So from:
    public interface MyInterface {
      String getText();
    }
    I can’t seem to use:
    class MyClass(val text: String): MyInterface
    c
    • 2
    • 3
  • e

    elect

    05/08/2018, 1:31 PM
    I think I have somewhere 1.6 dependencies, but is it possible that they are holding me back?
    i
    • 2
    • 1
Powered by Linen
Title
e

elect

05/08/2018, 1:31 PM
I think I have somewhere 1.6 dependencies, but is it possible that they are holding me back?
i

ilya.gorbunov

05/08/2018, 2:42 PM
No, the reason is that the task that compiles kotlin code is not configured properly.
View count: 2