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

    codeslubber

    05/31/2017, 7:31 PM
    @hhariri might be interesting to add a channel for adjudicating violations, a couple times when @orangy has run in to suppress something, I have thought an actual discussion would be fruitful.. 🙂
    h
    a
    • 3
    • 5
  • j

    javaru

    05/31/2017, 8:12 PM
    I'm having some difficulty figuring out the correct syntax for calling a Vararg with lambdas. The Kotlin converter in IDEA gave me what is shown below. But it results in a compile error. What's the syntax I need?
    public static void assertAll(String heading, Executable... executables)
    
    // "Executable" is an interface with a single "execute()" method
    
    // JAVA
    assertAll("test the 'add' method",
              () -> assertEquals(4, calculator.add(2, 2)),
              () -> assertEquals(5, calculator.add(2, 3))
    );
    
    // KOTLIN
    # the 'assertEquals' is underscored with error "None of the following functions can be called with the arguments supplied."
    assertAll("test the 'add' method", 
              { assertEquals(4, calculator.add(2, 2)) },
              { assertEquals(5, calculator.add(2, 3)) }
             )
    m
    • 2
    • 9
  • m

    marcoferrer

    05/31/2017, 8:40 PM
    I tried asking in the reflect channel and couldn’t get a response. It might be a dumb question but I figured I would ask here. Which of these approaches would be the most performant way of finding a constructor of a generic that takes an argument that is a subclass of type ‘Item’
    T::class.constructors.find {
           it.parameters.size == 1 &&
           it.parameters[0].type.isSubtypeOf(Item::class.createType())
    }
        
    T::class.constructors.find {
            it.parameters.size == 1 &&
            it.parameters[0].type.jvmErasure.isSubclassOf(Item::class)
    }
    i
    • 2
    • 2
  • t

    trevjones

    06/01/2017, 4:05 AM
    you can do something similar to that with a reified generic but kotin doesn’t have a Self type
    r
    • 2
    • 2
  • g

    gyl

    06/01/2017, 7:59 AM
    Thank you @nfrankel . I thinking about maybe a static code analyzer like PMD or FindBug for Kotlin
    t
    • 2
    • 1
  • o

    outlying

    06/01/2017, 9:21 AM
    Hello, I got one question about Kotlin-Java, when we use Kotlin we don’t write builders since we have named arguments + default values, that’s ok, but what in case we write library in Kotlin and this library will also be used in Java project? It would be messy, we end up with constructor with
    n
    arguments. Is there a way to generate proper builder for Java? Some sort of annotation like
    @JvmOverloads
    m
    k
    • 3
    • 6
  • m

    myanmarking

    06/01/2017, 9:21 AM
    my boss is ordering an android wearable watch for testing purposes. Any1 can give suggestions?
    o
    s
    +2
    • 5
    • 6
  • n

    nhaarman

    06/01/2017, 4:51 PM
    Is there some 'delegate' way to do the following?
    val container: Container
    var property: Int
      set(value) {
        container.property = value
      }
      get() {
        container.property
      }
    I was thinking about something like this, but that doesn't work obviously
    val container: Container
    var property: Int by container.property
    a
    • 2
    • 3
  • u

    user

    06/01/2017, 9:11 PM
    message has been deleted
    t
    • 1
    • 1
  • p

    paisrikanth

    06/02/2017, 6:34 AM
    Hey Guys, new to Kotlin so wanted to know what's the difference between "let" and "apply" block?
    k
    • 2
    • 1
  • m

    menegatti

    06/02/2017, 11:13 AM
    search for class fields that begin with m and remove it
    m
    • 2
    • 3
  • k

    kingsley

    06/02/2017, 11:24 AM
    Either one works. I prefer the second though, but it could also be context dependent
    j
    • 2
    • 4
  • a

    apatrida

    06/02/2017, 2:30 PM
    It is inline, and Java does not inline at compile time no?
    l
    k
    • 3
    • 2
  • k

    kingsley

    06/02/2017, 2:30 PM
    Yes. Reification is a Kotlin only feature. So it's not available to Java. If you try to call it via reflection for example, you'll get an
    UnsuportedOperationException
    l
    • 2
    • 1
  • n

    nyxcode

    06/02/2017, 3:57 PM
    Hey, can anyone explain to me what the difference is between a getter/setter and a delegate?
    a
    r
    • 3
    • 4
  • n

    nyxcode

    06/02/2017, 5:47 PM
    Hey! In exposed (https://github.com/JetBrains/Exposed), is it possible to have an entity without an ID?
    o
    • 2
    • 1
  • b

    bj0

    06/02/2017, 6:13 PM
    just put it in the body of your class
    val arrayCopy = ...
    ?
    ➕ 1
    r
    • 2
    • 1
  • n

    nulldev

    06/02/2017, 10:04 PM
    Is there an ETA on when reflection for Kotlin JS will come out? I've asked around for a
    JSON -> Kotlin JS Object
    de-serialization framework and since nobody seems to know of one, I plan to write one myself. Unfortunately, my job is severely hampered by the lack of reflection in Kotlin JS. I just want to know whether or not I should wait for reflection before I start or if I should just start but put in some hacky workarounds instead of using reflection.
    a
    • 2
    • 1
  • c

    chi

    06/03/2017, 4:51 AM
    Thanks for such a great language! I have a question, since Kotlin is interoperable with Javascript, what prevents the use of Kotlin for React Native apps?
    a
    • 2
    • 1
  • w

    wouterdoeland

    06/03/2017, 8:30 AM
    Kotlinx.HTML is escaping
    "
    to
    &quot
    , is there a fix for that?
    v
    • 2
    • 1
  • a

    andrewoma

    06/04/2017, 6:55 AM
    @ramsrib Without looking at it, a likely candidate would be kotlin classes being final by default preventing the creation of a proxy
    r
    • 2
    • 5
  • v

    vaskir

    06/04/2017, 7:17 AM
    why it's not possible to write
    .map(parser.parse)
    instead of
    .map { parser.parse(it) }
    ?
    m
    • 2
    • 2
  • z

    ziad

    06/04/2017, 4:11 PM
    I was wondering if any maven gurus or kotlin experts can point me towards a good way for me to make sure that I'm using Kotlin and Kotlin libraries that work nicely together in terms of version numbers.
    n
    • 2
    • 2
  • c

    chb0kotlin

    06/04/2017, 7:20 PM
    @brumla you don't understand the question. Let me give sample source:
    class Test(val thing:String, val other:Int)
    public class Authority implements GrantedAuthority {
    
        private User user;
    
    
        private String role;
    
        public Authority(User user, String role) {
            this.user = user;
            this.role = role;
    
        }
    
    }
    test code:
    public class Foo {
    
        public static void main(String[] args) {
            Arrays.stream(Test.class.getDeclaredConstructors()).map(Constructor::getParameters)
                    .flatMap(Arrays::stream).map(Parameter::getName).forEach(System.out::println);
    
            Arrays.stream(Authority.class.getDeclaredConstructors()).map(Constructor::getParameters)
                    .flatMap(Arrays::stream).map(Parameter::getName).forEach(System.out::println);
        }
    }
    output: arg0 arg1 user role if you compile the java code with
    -parameters
    you get the bottom 2 lines with java. Without it, you get the same as the 2 kotlin lines
    d
    • 2
    • 3
  • k

    kingsley

    06/04/2017, 7:40 PM
    How come this compiles successfully. Referencing the class fails at runtime with
    VerifyError
    open class Base(val me: String) {
    
      companion object : Base(string()) {
      
        private fun string() = "companion object"
        
      }
    }
    • 1
    • 1
  • b

    blakelee

    06/05/2017, 2:27 AM
    Is there any way around this?
    An annotation parameter must be a class literal (T::class)
    I want to do something like
    myclass<myType>::class.java
    It's looking like I'm going to have to define a class for each of my types 😞
    d
    • 2
    • 2
  • r

    redrield

    06/05/2017, 2:39 AM
    like
    operator fun shl(other: Foo): Foo { }
    could work on
    val foo = Foo(); foo << Foo()
    v
    • 2
    • 1
  • a

    adolev

    06/05/2017, 9:25 AM
    Hello, when I declare a typealias, am I supposed to be able to discriminate between the alias and the aliased type in a when expression?
    a
    • 2
    • 3
  • a

    andyr

    06/05/2017, 9:52 AM
    just a question is it possible to convert all java to Kotlin in IDEA intellij (i mean does this always work ?)
    t
    • 2
    • 6
  • c

    cy

    06/05/2017, 12:10 PM
    btw, what library is it?
    u
    • 2
    • 1
Powered by Linen
Title
c

cy

06/05/2017, 12:10 PM
btw, what library is it?
u

ugurk

06/05/2017, 2:48 PM
it is an internal library
View count: 1