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
getting-started
  • h

    Hullaballoonatic

    09/20/2018, 3:21 PM
    I thought that only affects whether or not you can expand or contract the size of the list
    r
    • 2
    • 11
  • h

    Hullaballoonatic

    09/20/2018, 6:41 PM
    i'll look into it
    k
    d
    • 3
    • 19
  • k

    karelpeeters

    09/20/2018, 6:58 PM
    I don't like
    repeat
    when you actually use the index, it reads wrong to me. So I'd replace that with a for loop instead. I always like the
    StringBuilder
    /
    apply
    combo, so that's fine IMO.
    s
    h
    • 3
    • 17
  • h

    Hullaballoonatic

    09/21/2018, 2:13 AM
    finished the project. thanks for all the help guys!
    v
    k
    • 3
    • 12
  • m

    Markchous

    09/21/2018, 2:57 PM
    Trying to update my Kotlin Version to
    1.3-M2
    so I can mess around with Coroutines
    0.26.0
    , but I'm getting this error:
    Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.3-M2.
    Searched in the following locations:
        <https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3-M2/kotlin-gradle-plugin-1.3-M2.pom>
        <https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3-M2/kotlin-gradle-plugin-1.3-M2.jar>
        <https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3-M2/kotlin-gradle-plugin-1.3-M2.pom>
        <https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3-M2/kotlin-gradle-plugin-1.3-M2.jar>
    Required by:
        project :
    l
    n
    i
    • 4
    • 10
  • a

    am

    09/22/2018, 6:36 AM
    Any good open source projects for beginners to start contributing in kotlin
    o
    • 2
    • 2
  • n

    Nikky

    09/22/2018, 7:47 PM
    so extract that somwhere and save it alongside your tablecells
    v
    • 2
    • 5
  • h

    Hullaballoonatic

    09/22/2018, 8:37 PM
    here's some context:
    g
    s
    • 3
    • 9
  • s

    Shawn

    09/23/2018, 12:03 AM
    @karelpeeters what’s up? 😅
    k
    • 2
    • 3
  • u

    ursus

    09/23/2018, 12:04 AM
    r u guys trolling me 😄 whats going on
    k
    • 2
    • 3
  • s

    Shawn

    09/23/2018, 10:01 PM
    where are you seeing that?
    v
    k
    i
    • 4
    • 25
  • o

    otakusenpai

    09/24/2018, 2:22 AM
    -.js
    e
    a
    • 3
    • 3
  • h

    Hullaballoonatic

    09/24/2018, 8:04 PM
    how do I make a constructor for a class that may throw an exception and thus does not instantiate?
    s
    • 2
    • 2
  • k

    karelpeeters

    09/25/2018, 7:17 AM
    Well it's not useful to do this,
    3, else
    is just
    else
    right?
    r
    k
    +3
    • 6
    • 20
  • p

    poohbar

    09/25/2018, 8:00 PM
    Am I doing something wrong?
    jacksonObjectMapper().convertValue("{\"name\":\"Jack\",\"age\":7}", Dog.class)
    data class Dog(
        val name: String,
        val age: Int
    )
    doing:
    objectMapper.convertValue<Dog>("{\"name\":\"Jack\",\"age\":7}")
    throws:
    Cannot construct instance of `com.example.Dog` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('{"name":"Jack","age":7}')
     at [Source: UNKNOWN; line: -1, column: -1]
    s
    • 2
    • 1
  • v

    ValV

    09/25/2018, 11:28 PM
    What does mean
    Cannot use 'CapturedTypeConstructor(out ObjectProperty<Any>)' as reified type parameter
    ?
    r
    • 2
    • 13
  • v

    ValV

    09/26/2018, 4:18 PM
    Ouch, seems that I can't override abstract
    StringConverter<T>
    with another parametric class
    r
    • 2
    • 15
  • v

    ValV

    09/26/2018, 6:26 PM
    out Any
    cannot be passed as
    reified
    , can it? When my code passes
    <SomeType, out Any>
    as
    <S, reified T>
    d
    • 2
    • 2
  • m

    matt tighe

    09/26/2018, 7:41 PM
    i’d like to take a
    HashMap
    and sort it by its keys, but i only really care about having a specific key at the beginning, the rest of them don’t matter. something like
    val myHashMap = HashMap<String, Int>
    myHashMap.put("hello", 0)
    myHashMap.put("world", 1)
    val sorted = myHashMap.toSortedMap(compareBy { it == "world" })
    can anyone help me figure out how to do that?
    d
    o
    • 3
    • 2
  • n

    Nikky

    09/26/2018, 9:30 PM
    the plugin warns you when it cannot inlineand so would kotlinc, i assume if it does not error .. that it inlines
    s
    k
    • 3
    • 8
  • s

    Sam

    09/26/2018, 10:28 PM
    it doesn't. Here testFilterType just returns the entire list and has no reified logic
    getFilteredList<Int>( list, List<Any?>::testFilterType  )
    
        private fun <T> List<Any?>.testFilterType() : List<Any?> {
    
            val filteredList = mutableListOf<Any?>()
    
            forEach {
                    filteredList.add( it )
            }
    
            return filteredList
        }
    
        private fun <T> getFilteredList( list : List<Any?>, filter : List<Any?>.() -> List<Any?> ) : List<Any?> {
            return list.filter()
        }
    n
    a
    • 3
    • 12
  • p

    Pat

    09/27/2018, 7:28 AM
    I am really new to Kotlin, coming from PHP. All the tutorials that I've seen so far tell me to use Gradle or Maven, but I don't really understand why I need them. The docs are pretty bad, they don't really explain what it does or why I need it, they just explain how to set it up. This is probably because I come from PHP, I don't think there is an equivalent thing there. Can someone shed some light for me on why I need Gradle/Maven and what they actually do?
    s
    t
    +2
    • 5
    • 8
  • c

    CamilleBC

    09/27/2018, 10:22 AM
    Hello ! I have a question on Coroutines. I have an Activity (it's for an android program, but the question itself hasn't much to do with android) that tries to connect to a socket using a coroutine. When it fails/succeeds, it calls another function. But the function is possibly executing in another thread, which makes it impossible to call a Toast for example. Is there anyway to have a coroutine call a function that executes in the parent thread ? EDIT: Replaced the pastebin with a public gist with my awful beginner code 🙂 https://gist.github.com/CamilleBC/bfe3b3234d52a0a501656d593c186108
    r
    s
    • 3
    • 13
  • s

    Sam

    09/27/2018, 3:34 PM
    noob question: Why isn't all inline functions reified by default?
    m
    • 2
    • 2
  • k

    karelpeeters

    09/27/2018, 3:36 PM
    Someone happened to ask the same thing yesterday 😒imple_smile:
    s
    • 2
    • 10
  • v

    ValV

    09/28/2018, 1:08 AM
    Is there any way to create named fields of a class dynamically run-time?
    m
    l
    k
    • 4
    • 4
  • c

    CamilleBC

    09/28/2018, 1:36 PM
    Hey! I am trying to cast a Boolean to String (true -> "1" | false -> "0"). This is because the API I am talking to uses 1 and 0. Is there a better way to do that than the method I am using?
    val boolToString = if (boolean) "1" else "0"
    h
    • 2
    • 4
  • k

    kaizo

    09/28/2018, 2:43 PM
    can I add a "!" or something else ?
    m
    • 2
    • 1
  • k

    kaizo

    09/28/2018, 2:47 PM
    yes
    h
    m
    +2
    • 5
    • 29
  • j

    Jukka Siivonen

    09/28/2018, 3:36 PM
    Right, is there any performance hit involved or is it just visibilty scope that is affected?
    🤷 1
    a
    • 2
    • 2
Powered by Linen
Title
j

Jukka Siivonen

09/28/2018, 3:36 PM
Right, is there any performance hit involved or is it just visibilty scope that is affected?
🤷 1
Looks like it behaves like an inner class, I've done lot of Java but never used a local class. Sorry for not Kotlin related :)
a

Alowaniak

09/28/2018, 3:47 PM
Yea it's not a very much used feature, in java that is
View count: 1