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

    Czar

    07/04/2017, 8:41 AM
    Well that's exactly kotlin's problem 🙂 Since it is solved for Kt collections, why not in J8 streams support? Added another map to the end of the chain (seems silly to me, but works):
    .map { it as SomeSpecificType }
    g
    • 2
    • 2
  • d

    dawidhyzy

    07/04/2017, 12:06 PM
    groups = arrayOf("g1")
    👍 2
    s
    • 2
    • 1
  • o

    ossama

    07/04/2017, 1:08 PM
    While reading about Companion objects, I’ve found this Note that, even though the members of companion objects look like static members in other languages, at runtime those are still instance members of real objects Can you tell me, please, why they are used with different form then if they are instance members ?
    a
    e
    +2
    • 5
    • 12
  • e

    evanchooly

    07/04/2017, 1:59 PM
    seems like 1.2 is looking to change that...
    😠 1
    p
    • 2
    • 2
  • j

    jw

    07/04/2017, 4:33 PM
    Look at how screwed all of Groovy is because everything is public.
    👍 2
    😆 2
    m
    n
    • 3
    • 3
  • r

    ross_a

    07/04/2017, 4:42 PM
    As an API writer I’m actually looking forward to Java Modules should they ever be released
    n
    • 2
    • 1
  • j

    jw

    07/05/2017, 3:58 AM
    @groostav Use compile-testing from Google
    g
    • 2
    • 1
  • z

    zeugederunity

    07/05/2017, 11:09 AM
    Hi, i was playing around with inline, noinline ect. and i managed to get a reproducible back-end exception from the compiler ( Exeption See: https://pastebin.com/6WU3Tesk ) Before i report the issue: are there any additional logfiles/dumpfiles generated from the compiler, that are of use for the Dev-Team?
    k
    • 2
    • 1
  • m

    menegatti

    07/05/2017, 12:30 PM
    public fun <T> Foo(T target) where T : Controller, T: OnDoneCheck { }
    k
    • 2
    • 1
  • t

    tarlekon

    07/05/2017, 2:26 PM
    hello, does anyone can help me with
    K2JVMCompiler
    ?
    o
    n
    i
    • 4
    • 25
  • a

    aa

    07/05/2017, 3:31 PM
    anyone here know the demo app
    thinkter
    well?
    o
    • 2
    • 2
  • k

    kevinmost

    07/05/2017, 6:47 PM
    return Unit.INSTANCE;
    n
    k
    • 3
    • 10
  • b

    badlogic

    07/05/2017, 10:01 PM
    "Run as" crashes Eclipse Oxygen
    o
    • 2
    • 8
  • b

    badlogic

    07/05/2017, 10:01 PM
    i know this is heathen level stuff, but i'm literally asking for a friend who has not seen the intellij light yet
    o
    • 2
    • 2
  • b

    bloodshura

    07/06/2017, 12:41 AM
    So, the
    when
    clause must only be exhaustive when it's a single-expression function or assignment?
    g
    • 2
    • 1
  • r

    rockerhieu

    07/06/2017, 6:55 AM
    I have a Java class:
    public final class Utils {
      public static void somethingUseful() {}
    }
    I don't see any suggestion to import the static method
    Utils.somethingUseful()
    when writing Kotlin code. Do I need to configure the Kotlin IDEA plugin?
    g
    c
    • 3
    • 10
  • e

    evanchooly

    07/06/2017, 12:08 PM
    you're welcome 😄
    s
    d
    +2
    • 5
    • 7
  • r

    rajendhiraneasu

    07/06/2017, 12:42 PM
    hi guys, just i'm a beginner to kotlin progra, any one can explain what is the difference between abstract and interface in kotlin?
    x
    • 2
    • 2
  • g

    groostav

    07/07/2017, 2:26 AM
    Arrays are funny.
    k
    • 2
    • 3
  • r

    rockerhieu

    07/07/2017, 8:10 AM
    In Kotlin all classes are final by default. What is the best practice to make a class
    open
    only in unit test?
    g
    • 2
    • 1
  • s

    semyon.atamas

    07/07/2017, 1:05 PM
    looks like coroutines jar needs some permissons from security manager. I'll take a look and if it's safe to grand those permissions I'll fix it
    👍 1
    v
    • 2
    • 2
  • p

    Paul Woitaschek

    07/07/2017, 5:19 PM
    AssertJ only on my side
    ➕ 1
    g
    • 2
    • 1
  • d

    dumptruckman

    07/08/2017, 4:03 AM
    If I'm trying to Kotlinize and add some convenience to this Java API where there's `Thing SomeSingleton.getThing(String)`(a lookup method which may return null), what would be the most idiomatic way to add this to CharSequence?
    fun CharSequence.getThing(): Thing?
    or
    val CharSequence.thing: Thing?
    feels wrong because it makes seem like the Thing belongs to the CharSequence.
    fun CharSequence.toThing(): Thing?
    feels wrong because it seems like this should throw an exception if the Thing is not found I'm not really sure what's left. Thoughts?
    v
    • 2
    • 2
  • e

    ensirius

    07/08/2017, 6:42 AM

    http://i.imgur.com/iwA6PZH.png▾

    k
    • 2
    • 17
  • o

    orangy

    07/08/2017, 2:50 PM
    https://www.tiobe.com/tiobe-index/ Lost 5 positions down to 48, but sitll in top 50 🙂
    t
    • 2
    • 2
  • d

    devesh525s

    07/08/2017, 5:23 PM
    ok, If I go by that way, learning by my knowledge of python, that's ok
    👍 1
    n
    • 2
    • 3
  • d

    dumptruckman

    07/08/2017, 5:25 PM
    I will say though, you'll sometimes find explanations of things to be... lacking
    v
    • 2
    • 2
  • m

    mplacona

    07/09/2017, 10:33 AM
    Hey Kotlin enthusiasts.. I just wrote a little class for a binary clock I'm building, and have made the code as small as I possibly could with my limited knowledge of Kotlin. Though I think there are still some optimisations to be made. Wondering if anyone here would care to have a look... https://github.com/mplacona/Binary-Watch/blob/master/app/src/main/java/rocks/androidthings/binaryclock/MainActivity.kt#L36
    v
    • 2
    • 9
  • g

    greybird

    07/09/2017, 4:22 PM
    @jschneider In Java I think
    throws Throwable
    implies that a subclass of Throwable may be thrown. So perhaps you don't need the generic type param, from the Java perspective at least. Are you using type E elsewhere in the method?
    j
    • 2
    • 3
  • b

    bloodshura

    07/10/2017, 2:47 AM
    Let's say that I have a method declared in a Java class, called
    getContent()
    , which returns a String? (it is annotated as
    @Nullable
    ). However, in the same class, there is another method called
    isOk()
    , which returns a Boolean. If
    isOk()
    returns
    true
    , it means that the String returned by
    getContent()
    will not be null. Is there any way (like a JSR-305 annotation maybe) I can tell the Kotlin compiler about this? For now, I'm doing the obvious:
    if (response.isOk) {
        val content = response.content!!
    }
    But I don't feel well at all having to use
    !!
    ...
    a
    e
    +5
    • 8
    • 12
Powered by Linen
Title
b

bloodshura

07/10/2017, 2:47 AM
Let's say that I have a method declared in a Java class, called
getContent()
, which returns a String? (it is annotated as
@Nullable
). However, in the same class, there is another method called
isOk()
, which returns a Boolean. If
isOk()
returns
true
, it means that the String returned by
getContent()
will not be null. Is there any way (like a JSR-305 annotation maybe) I can tell the Kotlin compiler about this? For now, I'm doing the obvious:
if (response.isOk) {
    val content = response.content!!
}
But I don't feel well at all having to use
!!
...
a

agrosner

07/10/2017, 4:14 AM
if (response.isOk) { val content = response.content ?: "" }
e

evanchooly

07/10/2017, 7:44 AM
or
response.content?.let { ... }
m

michaelzinn

07/10/2017, 7:45 AM
or
response.content?.let { content -> ...
if you want to keep the val’s name.
Would
response.isOk and respone.content?.let { content -> {
work?
m

marstran

07/10/2017, 8:14 AM
You can do
response.takeIf { it.isOk }?.content?.let { content -> ... }
if you need to check
isOk
. But I think I would use the normal if-test, as most people would find it more readable.
p

Paul Woitaschek

07/10/2017, 8:21 AM
Response.isOk is kind of obsolete right?
Why not just
if(response.content != null) ... else ...?
Or if you don't have an else statement just
response.content?.let {....}
m

marstran

07/10/2017, 8:23 AM
I don't know which library this is from, but
isOk
might check for more than just
response.content != null
though.
e

evanchooly

07/10/2017, 8:40 AM
isOk
likely is an http response code check. things can be
OK
without a response body.
k

karelpeeters

07/10/2017, 8:54 AM
This issue asks about that: https://youtrack.jetbrains.com/issueMobile/KT-14397
d

danneu

07/10/2017, 12:36 PM
had the same question yesterday in another channel 😛
View count: 1