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

    janvladimirmostert

    09/11/2017, 12:28 PM
    yeah, I've removed it, it says construction is not yet supported in inline functions
    i
    • 2
    • 7
  • k

    karelpeeters

    09/11/2017, 3:04 PM
    The compiler could technically see that
    test(InInt(5))
    has type
    Out<Int>
    and the only possibility is that it's actually
    OutInt
    , but it's not that advanced.
    j
    • 2
    • 2
  • m

    myanmarking

    09/11/2017, 4:08 PM
    Typeface.create(“roboto…“, Typeface.NORMAL)
    does this needs to be cached?
    k
    • 2
    • 2
  • e

    evkaky

    09/11/2017, 4:40 PM
    guys, is there any discussion or explanation about, why no union/intersection types (like in typescript) in kotlin? I don’t think, that it’s a must have feature, but I think this topic is quite interesting and was already discussed
    j
    k
    d
    • 4
    • 9
  • r

    Ruckus

    09/11/2017, 5:23 PM
    Is there a reason the
    CollectionsKt.binarySearch
    functions aren't inline?
    m
    • 2
    • 1
  • d

    dimsuz

    09/11/2017, 9:59 PM
    Hmm, according to this https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-channel-iterator/,
    hasNext()
    and
    next()
    are operators available to overloading? But they a not mentioned in kotlin reference - is this a missing documentation or am I understanding it wrong? https://kotlinlang.org/docs/reference/operator-overloading.html
    k
    • 2
    • 4
  • s

    snowe

    09/11/2017, 11:21 PM
    anyone here use ktlint?
    a
    s
    • 3
    • 8
  • s

    sqia09

    09/12/2017, 7:13 AM
    Hi, I've got a query regarding the new Parcelable implementation in android-extensions which enables you to annotate a model class with @Pacelize. but I'm having issues using it, as my models contains @SerializedName annotation and there are Arraylist properties too. So can anyone help me out?
    g
    • 2
    • 10
  • a

    arjunbvb

    09/12/2017, 8:06 AM
    Is there any option to disable text selection (copy paste) option at project level like a manifest setting or something ?
    :android: 3
    :stackoverflow: 3
    e
    g
    • 3
    • 3
  • k

    karelpeeters

    09/12/2017, 9:42 AM
    I don't really think that's better though.
    g
    j
    • 3
    • 8
  • l

    lpirro

    09/12/2017, 10:04 AM
    @kristofdho I want to use
    let
    because if not null not works with mutable properties, and you need to use !!
    g
    • 2
    • 1
  • k

    karelpeeters

    09/12/2017, 10:10 AM
    Try
    obj?.let { ... } ?: run { ... }
    .
    g
    • 2
    • 3
  • d

    diego-gomez-olvera

    09/12/2017, 10:13 AM
    if
    v
    is
    val
    ,
    if
    can smart-cast to non nullable
    g
    • 2
    • 1
  • s

    Slackbot

    09/12/2017, 12:26 PM
    This message was deleted.
    :stackoverflow: 1
    k
    m
    d
    • 4
    • 3
  • k

    kristofdho

    09/12/2017, 12:28 PM
    i took a look at enumsets too and i don't see why you would still need to asign the bit values to your enum
    k
    d
    • 3
    • 2
  • d

    dave08

    09/12/2017, 12:30 PM
    I need to make an enum for android ApplicationInfo flags:
    enum class PackageFlags(val mask: Int) {
    	NONE(0), SYSTEM_APP(1), IS_DEBUGGABLE(2), SYSTEM_APP_UPDATED(128), IN_SD_CARD(262144),
    	IS_DATA_ONLY(16777216), IS_STOPPED(2097152)
    }
    e
    • 2
    • 7
  • d

    dave08

    09/12/2017, 1:38 PM
    enum class PackageFlags(val mask: Int) {
        NONE(0), SYSTEM_APP(1), IS_DEBUGGABLE(2), SYSTEM_APP_UPDATED(128), IN_SD_CARD(262144),
        IS_DATA_ONLY(16777216), IS_STOPPED(2097152)
    }
    The function invoke() is not found
    n
    • 2
    • 5
  • j

    jacobmoncur

    09/12/2017, 5:20 PM
    JB team: How do the runnable snippets on the coroutines reference page (https://kotlinlang.org/docs/reference/coroutines.html) work? Are they available as a js lib/api somewhere? I’d love to make/see external blogposts with these
    b
    r
    • 3
    • 2
  • d

    damian

    09/12/2017, 5:25 PM
    anyone aware of some classpath bugs when using
    kotlin.compiler.execution.strategy="in-process"
    ? I am seeing
    java.lang.ClassCastException: com.sun.tools.javac.api.JavacTrees cannot be cast to com.sun.source.util.Trees
    when calling
    Trees.instance(processingEnv)
    in a processor through kapt
    • 1
    • 1
  • e

    eginez

    09/12/2017, 10:10 PM
    I'd like to read a file and compile it after I load some dependencies into the jvm
    k
    • 2
    • 1
  • m

    mike_shysh

    09/13/2017, 7:41 AM
    Hi, Is there some info about kotlin's threadLocal analogue?
    g
    • 2
    • 2
  • p

    pniederw

    09/13/2017, 7:54 AM
    @edwardwongtl these are nested not inner classes, and they can reference each other’s constructor just fine in general (only a problem with
    sealed
    )
    e
    • 2
    • 2
  • r

    rrader

    09/13/2017, 8:24 AM
    How do you name a class and the name should stand for: iPhoneX, iOS ? Do you name them IPhoneX and IOS? or how do you name a class if the name in real world starts with lowercase letter?
    k
    g
    c
    • 4
    • 23
  • s

    sqia09

    09/13/2017, 9:56 AM
    Hi, I can't seem to pass my parcelable arrays to other activity, so is there anyone who can help me out/
    g
    • 2
    • 30
  • s

    sqia09

    09/13/2017, 10:25 AM
    has anyone used @Parcelize?
    g
    k
    • 3
    • 5
  • g

    geatmo

    09/13/2017, 1:30 PM
    a few days ago somewhere in here I learned of this nice pattern to create a populated list:
    val myList = List(3) { it }
    which, as the documentation states, creates a read-only list.. but as far as I can see, this list only appears to really be read-only, as I am able to do this:
    (myList as MutableList).clear()
    and the list will get modified.. so for actually immutable lists, should I better stick to keep using
    listOf()
    instead?
    k
    • 2
    • 3
  • n

    nish

    09/13/2017, 5:25 PM
    Is there a comprehensive list of who’s using kotlin?
    o
    k
    • 3
    • 3
  • m

    michael.barker

    09/13/2017, 8:01 PM
    Is there a recommended convention for naming boolean properties? In Java I wouldn't use an
    is
    prefix since the getter becomes getIsValid. From what I found with Java interoperability a property with the
    is
    prefix ends up with a getter named isValid.
    d
    • 2
    • 1
  • d

    Dalinar

    09/14/2017, 6:32 AM
    really wish :kotlin-flag: would have some kind of
    postInit { }
    or
    ready { }
    block that is called in the parent after all subclasses are fully constructed. Right now I'm implementing an abstract fun() that the child must override (to ensure that all subclasses always call the parent initializer method) (at the bottom of the child class) to call an initalize() fun in the parent. I'm wondering if there is a better way? Because the code that I would normally put in the
    init { }
    block needs to reference an abstract val that (implemented in the child) references a constructor property of that child
    c
    k
    +5
    • 8
    • 52
  • p

    pniederw

    09/14/2017, 9:33 AM
    still hoping for an answer: is this compile error expected, and if so, what’s the rationale?
    class Outer {
      sealed class Foo {}
      
      // cannot access '<init>': it is private in 'Foo'
      class Bar : Foo() {}
    }
    o
    n
    s
    • 4
    • 11
Powered by Linen
Title
p

pniederw

09/14/2017, 9:33 AM
still hoping for an answer: is this compile error expected, and if so, what’s the rationale?
class Outer {
  sealed class Foo {}
  
  // cannot access '<init>': it is private in 'Foo'
  class Bar : Foo() {}
}
o

orangy

09/14/2017, 9:35 AM
@stanislav.erokhin
n

nil2l

09/14/2017, 9:39 AM
Maybe it is as rules changed in 1.1?
A sealed class can have subclasses, but all of them must be declared in the same file as the sealed class itself. (Before Kotlin 1.1, the rules were even more strict: classes had to be nested inside the declaration of the sealed class).
p

pniederw

09/14/2017, 9:40 AM
what do you mean by “it is as rules changed”?
it is expected?
n

nil2l

09/14/2017, 9:41 AM
I mean before 1.1 you could declare it as inner class. After — only as few classes in one file (and not as inner classes).
p

pniederw

09/14/2017, 9:41 AM
1.1 lifted some restrictions, it didn’t add any
but apparently the enhancements in 1.1 don’t extend to the nested class case. I wonder if they should.
n

nil2l

09/14/2017, 9:43 AM
Isn’t this a restriction?
all of them _must_ be declared in the same file as the sealed class itself
p

pniederw

09/14/2017, 9:43 AM
no
(not compared to 1.0)
s

stanislav.erokhin

09/14/2017, 9:44 AM
It is expected behaviour for now. In 1.0 subclasses for sealed classes was allowed only inside corresponding class, and in 1.1 we allow top-level subclasses for top-level sealed classes. We can support such cases later.
View count: 2