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

    mkporwit

    07/14/2017, 12:13 AM
    Tried putting it in an array. IntelliJ complains that it expects a
    String!
    but got
    Array<String>
    instead
    m
    • 2
    • 1
  • h

    haxpor

    07/14/2017, 1:54 AM
    Android studio often suggests me that I can use stdlib operation i.e.
    filter{}
    ,
    map{}
    over normal loop code. Yes, I like to use those. But peek into the code from IDE reveals that actually
    filter{}
    is not better than normal loop as it dynamically creates a new
    ArrayList
    object to hold filtered elements. So normal loop would slightly has better performance. My question is as IDE suggests me like this - Is the performance that significant (although I can’t feel any difference)? - Is there anyone already did performance test comparing between
    filter{}
    ,
    map{}
    etc against normal way? - Should I always use lambda functions as also suggested by IDE? (I want to but from above, I didn’t feel safe)
    m
    • 2
    • 18
  • r

    rednifre

    07/14/2017, 4:21 PM
    Does Kotlin work well for writing command line tools? Can you do "myprogram -b" or do you have to do something like "java -jar myprogram.jar -b" ?
    a
    u
    h
    • 4
    • 6
  • i

    ilyagulya

    07/14/2017, 4:29 PM
    Hello, guys. How can i do such thing: I have project with Java and Kotlin interop. I want to use closures like this:
    (Int) -> Unit
    and provide them from Java to Kotlin. However, in Java i need to provide
    Function1<Int, Unit>
    instead of
    Consumer<Int>
    or something like this. Due to this limitation i need to return
    Unit.INSTANCE
    or use custom interfaces instead of closures How can i avoid this problem?
    r
    • 2
    • 5
  • z

    ziggy42

    07/14/2017, 5:16 PM
    Oh cool I didn't know that, thanks
    d
    • 2
    • 1
  • g

    gregd

    07/14/2017, 5:25 PM
    Hi all :kotlin: Is there any way to disable asserted
    !!
    calls altogether?
    d
    k
    • 3
    • 14
  • k

    kevinmost

    07/14/2017, 6:55 PM
    val str : String? = ""
    str{THIS_IS_NOT_SAFE_PLS_PAY_ATTENTION}.length
    😉
    k
    • 2
    • 1
  • d

    dumptruckman

    07/14/2017, 11:32 PM
    is it possible to coerce the compiler change the namespaces of the automatic kotlin includes?
    s
    • 2
    • 1
  • s

    supaham

    07/16/2017, 6:39 PM
    is
    WeakReference<Entity?>
    more proper than
    WeakReference<Entity>
    . If I had to guess, I'd say it will always NPE after GC
    d
    k
    • 3
    • 4
  • d

    diesieben07

    07/16/2017, 6:59 PM
    Delegates.vetoable
    ?
    s
    k
    • 3
    • 4
  • s

    simkis

    07/17/2017, 12:42 PM
    Hello. How can i convert this java interface
    public interface Listener{
            void success(Model model);
    
            void error();
        }
    to make it useable from kotlin without annonymous inner class? Do I need to declare interface with only one method? Or there is some other workaround? I want to use it like this
    modelManager.identifyModelWithCameraUrl(cameraUrl) { cameraModel ->
                
            }
    m
    • 2
    • 1
  • m

    mfiano

    07/18/2017, 8:13 AM
    Sounds cool to me. I'm trying to install IntelliJ Idea now on Linux, but the fonts look absolutely horrible and unreadable no matter which I choose
    k
    • 2
    • 1
  • d

    diesieben07

    07/18/2017, 9:46 AM
    Kotlin documentation uses markdown, so you'd use
    [MyClass]
    .
    👍 1
    o
    • 2
    • 1
  • j

    jw

    07/18/2017, 2:29 PM
    try #salt or #random
    l
    • 2
    • 1
  • o

    orangy

    07/18/2017, 4:58 PM
    Just to give you a little bit of perspective, browse these images to get an impression of how 10K people look like. When you post off-topic here, this is how many people can be potentially affected. Sure, there are much less active people here, but still. https://www.google.com/search?q=10000+crowd&amp;tbm=isch
    • 1
    • 1
  • o

    orangy

    07/18/2017, 5:41 PM
    Why there is no reaction such as `tired_police_car`…
    😫 1
    😆 1
    k
    m
    • 3
    • 2
  • m

    mfiano

    07/18/2017, 7:30 PM
    @tulio Actually I switched from openjdk7 to 8 and the problem seemed to fix itself.
    👍 1
    a
    • 2
    • 8
  • n

    napperley

    07/19/2017, 6:40 AM
    Trying to launch the Kotlin REPL to do some prototyping using TornadoFX (using Kotlin 1.1.4 EAP 22) but end up with the following errors: Error: Could not find or load main class org.jetbrains.kotlin.preloading.Preloader 🙁. Using the following path in the terminal: ~/kotlin-build-1.1.4-eap-22/compiler/cli/bin/kotlinc.
    l
    • 2
    • 1
  • m

    mfiano

    07/19/2017, 7:16 AM
    Hadi at JetBrains said that his 1.1.3 branch of his tutorial code was up to date with any deprecations, but only the first one produces any output here https://github.com/hhariri/oreilly-kotlin-course/blob/kotlin-1.1.3/intro/src/com/hadihariri/kotlincourse/basics/LoopsAndRanges.kt#L20-L26
    g
    o
    b
    • 4
    • 11
  • l

    lorinc

    07/19/2017, 1:07 PM
    and it points to https://kotlinslackin.herokuapp.com
    r
    • 2
    • 1
  • j

    jackmiras

    07/19/2017, 3:33 PM
    Yes we could, but what if the team is trying to avoid nullability hard as they can? Of course that we could write some function to work around this but would much nicer if this kind of feature was provide natively.
    r
    • 2
    • 1
  • o

    orangy

    07/19/2017, 9:37 PM
    @Ruckus that’s it! but there are more 🙂
    r
    • 2
    • 2
  • a

    alenkart

    07/19/2017, 10:33 PM
    Thank you!!!
    👍 1
    k
    • 2
    • 1
  • g

    ghosalmartin

    07/20/2017, 9:32 AM
    anyone know why you are not able to check if something thats lateinit's state
    h
    • 2
    • 2
  • g

    galex

    07/20/2017, 12:39 PM
    Question about coroutines and if what I’m doing is counter-productive: I’ve got 111 urls to download and used coroutines with async {} to do it in parallel. By using CommonPool it takes 10 seconds but by using async(newSingleThreadContext()) per url I get to 6 seconds, almost twice as fast! It’s a gradle plugin meaning a few seconds after downloading all the data the program finishes so I am not worried about the number of threads. Does this makes sense to do it the way I did or is there a better way to be faster while using less threads?
    c
    g
    x
    • 4
    • 6
  • n

    nyxcode

    07/20/2017, 6:07 PM
    An snippet of what I'm trying to do:
    interface SerializationAdapter<T : Any> {
        fun serialize(obj: T, output: ByteBuf)
        fun deserialize(input: ByteBuf): T
    }
    data class PacketDeclaration<T : Packet>(val id: Int,
                                                                           val clazz: KClass<T>,
                                                                           val serializer: SerializationAdapter<T>)
    interface PacketRegistry {
        fun <P : Packet> resolve(clazz: KClass<P>): PacketDeclaration<P>
    }
    fun serialize(byteBuf: ByteBuf, packet: Packet) {
        val registry = ...
        val dec = registry.resolve(packet::class)
       dec.serializer.serialize(packet, byteBuf)
       // ^^ Out-projected type 'SerializationAdapter<out Packet>' prohibits the use of 'public abstract fun serialize(obj: T, output: ByteBuf): Unit defined in de.nyxcode.dmn.protocol.SerializationAdapter
    }
    Any recommendations?
    d
    g
    • 3
    • 10
  • p

    Paul Woitaschek

    07/21/2017, 8:20 AM
    Where is a good place for suggesting new inspections?
    v
    • 2
    • 1
  • r

    raulraja

    07/21/2017, 11:17 AM
    I'm working on implementing PartialFunctions in Kotlin so you can do
    collect
    to
    map
    and
    filter
    in one pass.
    s
    • 2
    • 1
  • p

    Paul Woitaschek

    07/21/2017, 12:18 PM
    Right now it's really painful cutting snippets by hand and pasting them in another part of the file
    ➕ 1
    d
    • 2
    • 2
  • g

    gregd

    07/21/2017, 1:24 PM
    How come Swift can work without it? (I'm not mentioning JS, since it's a quite different story)
    v
    e
    • 3
    • 10
Powered by Linen
Title
g

gregd

07/21/2017, 1:24 PM
How come Swift can work without it? (I'm not mentioning JS, since it's a quite different story)
v

voddan

07/21/2017, 1:26 PM
Because in kotlin you can have a method
foo()
and a value
foo
in one scope (separate name spaces for functions and properties)
g

gregd

07/21/2017, 1:33 PM
Not sure if that convinces me actually. Looking at the direction in which the languages are heading, having hassle-free support for passing functions seems like a higher-priority IMO
e

elizarov

07/21/2017, 1:43 PM
You can always define
val foo = this::foo
in Kotlin and have hassle-free for both
foo(...)
invocations and passing
foo
around as a value. I’m not sure if that helps in your case, though.
g

gregd

07/21/2017, 1:51 PM
Thanks. I know that. But it's not hassle-free, since I have to define the property first 😉
I just see there's a clear trend towards Functional Programming recently, that's why I'm a bit concerned about Kotlin's not-ideal syntax for this.
e

elizarov

07/21/2017, 2:28 PM
I see a clear tread towards Functional Programming for the past 20 years. People who are older than me had reported seeing it for the past 40 years
When you are experienced developer, you don’t usually get confused by the code that freely mixes values and functions. It is a big challenge for novices, though. I do believe that Kotlin’s explicitness, that is a clear separation of functions and the fact that it does not have anything like Swift’s
autoclosure
is helping to make Kotlin code easier to read and understand for the less experienced crowd.
g

gregd

07/21/2017, 3:43 PM
Most people would probably say that 80's, 90's and early 2k's were all about OOP, but ok 😉
Let's just hope that at least
KT-15667
will make it into :kotlin: 1.2
Anyways, I admire your hard work! Thanks! 👍 😄
View count: 1