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

    kuno

    10/20/2018, 5:11 AM
    Need help on Android development here
    h
    • 2
    • 2
  • u

    Uzi Landsmann

    10/20/2018, 5:58 AM
    Hi! I'm stuck and am getting no answers in Stackoverflow. Anyone cares to take a look? https://stackoverflow.com/questions/52811359/how-to-get-the-type-of-an-instance-of-javax-lang-model-element-element
    n
    • 2
    • 1
  • b

    bod

    10/20/2018, 1:47 PM
    Hello, World! Is it a known problem that when using coroutines in IntelliJ, we get a warning about it being experimental that links to this page, which is a
    404
    ? https://kotlinlang.org/docs/diagnostics/experimental-coroutines
    h
    • 2
    • 5
  • n

    Nikky

    10/20/2018, 9:54 PM
    well i just hope for the best and so on
    k
    • 2
    • 2
  • n

    Nikky

    10/21/2018, 12:11 AM
    is there a dedicated channel here for questions regarding data2viz ?
    h
    g
    • 3
    • 4
  • t

    TwoClocks

    10/21/2018, 3:56 AM
    is there an opposite to "inner" for classes? I want my inner class to have some private data/method that's only callable/modifiable from the outer class. Can't quite figure out how to do that. This must be a common thing, no?
    k
    • 2
    • 3
  • j

    JoeHegarty

    10/21/2018, 4:15 AM
    Data classes are great for configuration and such when used from Kotlin, but they are kind of awkward when used from Java. Is there an easy way to generate a builder style wrapper for a data class? Similar to the
    @builder
    annotation in Lombok etc. Has anyone created an annotation processor or similar that does this?
    k
    • 2
    • 2
  • z

    zake

    10/21/2018, 8:06 AM
    Does anybody know if I can run kotlin code generated with javac version 1.8 with a java version 10 jre?
    j
    • 2
    • 3
  • k

    karelpeeters

    10/21/2018, 7:15 PM
    In most cases the JVM needs to do the null check anyway to possibly throw nullpointerexceptions, and so it can optimize the redundant one away.
    u
    • 2
    • 1
  • s

    Slackbot

    10/21/2018, 10:01 PM
    This message was deleted.
    k
    • 2
    • 1
  • b

    Barend

    10/22/2018, 10:36 AM
    Hi! How can I view which lines contain errors? Now, in Analysis it just says "2 errors found, 2 warnings found". Does Android Studio have anything like "View: Toggle Problems" in Visual Studio Code?
    h
    • 2
    • 2
  • g

    Giorgio Antonioli

    10/22/2018, 10:40 AM
    Hi everyone, Dagger 2.18 supports incremental annotation processing. With mixed Java/Kotlin source sets can it be used? As far as I know kapt doesn't support incremental annotation processing yet. Are there any solutions that I'm not aware of?
    k
    • 2
    • 2
  • d

    Daniele Segato

    10/22/2018, 3:58 PM
    According to many difference sources on the web
    by lazy
    can cause memory leaks. Notable one: https://twitter.com/chrisbanes/status/897075635142754305 Is this an old issue that has been solved in recent versions of kotlin or is it still a "gotcha" that the developer has to take care of? If still a gotcha, any suggestion on how to handle values that might not be initialized? As far as I understand I can't access the delegate directly.
    m
    e
    +2
    • 5
    • 43
  • a

    adolev

    10/22/2018, 4:14 PM
    Thanks for your reply! It does not seem to work. I want to add a getEnv method, which throws an Exception if the environment variable does not exists.
    h
    s
    • 3
    • 4
  • a

    adolev

    10/22/2018, 4:16 PM
    OK, I see. I do think it could be useful though
    s
    • 2
    • 2
  • w

    william

    10/22/2018, 11:36 PM
    Hi everyone - i am writing a parse function on a Command model that I am taking (can be thought of as modeling any prompt based command). So this command is made up of arguments, e.g. an arugment for the
    ping
    command would be
    -n 3
    where
    -n
    is the name and
    3
    is the value. One of the things I am stuck on is writing a parse function on the input that will output a type based on what the argument type. So in this example for
    -n 3
    we would want the value returned to be
    3
    which is an
    Int
    . In some other cases we would want to parse as a string, boolean, etc. I am not sure how to make this generic to allow for any return types. I thought about doing something like
    fun <T> parse(text: String, conversion: (String) -> T): T
    where I could pass in a conversion function to turn a string into whatever value I wanted but I don't know how to supply a default value to that e.g. if none is provided just return it as a string. Thoughts?
    n
    t
    • 3
    • 28
  • v

    Varun Sharma

    10/23/2018, 9:19 AM
    Can we use kotlin for machine learning?
    :yes: 2
    e
    • 2
    • 1
  • k

    kiffin

    10/23/2018, 9:54 AM
    I'm trying to create a new Intellij project using the ktor plugin wizard but having problems
    n
    • 2
    • 1
  • s

    sp33dy

    10/23/2018, 12:53 PM
    Hi all, in fact, I've kept my connectivity! May I ask about the best approach with a Tornadofx solution?
    h
    • 2
    • 3
  • g

    GarouDan

    10/23/2018, 12:56 PM
    Guys, is there a way to get all arguments passed to a function? For example something like:
    fun myFunction(arg1: Type1, arg2: Type2, ..., argn: TypeN) {
       val arguments = getAllArguments()
    }
    e
    b
    • 3
    • 9
  • s

    shikhar1234

    10/23/2018, 2:37 PM
    guys is there anything like a community of android developers in Toronto,Canada?
    r
    r
    • 3
    • 4
  • l

    luke_c

    10/23/2018, 3:24 PM
    How does default parameters in interfaces work? The IDE complains if you try to implement the interface function with the default parameter but it doesn’t seem to mind if you leave it out
    s
    e
    h
    • 4
    • 7
  • s

    Slackbot

    10/23/2018, 3:29 PM
    This message was deleted.
    s
    h
    • 3
    • 5
  • g

    gildor

    10/24/2018, 6:18 AM
    Is code of
    <http://play.kotlinlang.org|play.kotlinlang.org>
    opensourced? I cannot find it. Would be good to update kotlinx.coroutines version there
    👍 1
    e
    k
    • 3
    • 7
  • s

    suppoze

    10/24/2018, 9:01 AM
    Hi all, just a quick question: The difference between this:
    val Foo = Bar()
    and
    val Foo
       get() = Bar()
    is that when using getter, the evaulation happens every time when accessing
    Foo
    , right?
    🙏 1
    :yes: 6
    r
    c
    a
    • 4
    • 6
  • m

    marcinmoskala

    10/24/2018, 9:23 AM
    I consider another name change from Kot. Academy to Kt. Academy. We already have domain kt.academy. Comments?
    👍 9
    r
    h
    +2
    • 5
    • 14
  • p

    Praemix

    10/24/2018, 10:20 AM
    I have a little question.. I do not know if I should choose Kotlin or Scala and why?
    :kotlin: 14
    e
    m
    +4
    • 7
    • 10
  • t

    Tsvetozar Bonev

    10/24/2018, 1:48 PM
    If I call a function and use the .? operator, will the function not be called when the .? fails?
    k
    • 2
    • 14
  • g

    GarouDan

    10/24/2018, 1:52 PM
    Guys, is there a way to automatically make available the getters and setters of a property? For example
    class MyIn {
    	fun myFunction() {
    		println("myFunction")
    	}
    }
    
    class MyOut {
    	val myIn: MyIn = MyIn()
    }
    
    class Test {
    	fun main() {
    		val myOut = MyOut()
    
    		// Calling myFunction from the myIn object this way. Maybe something with delegate?
    		myOut.myFunction()
    	}
    }
    t
    p
    s
    • 4
    • 6
  • m

    Matheus

    10/24/2018, 2:22 PM
    pass clientProvider to TestService?
    t
    h
    • 3
    • 18
Powered by Linen
Title
m

Matheus

10/24/2018, 2:22 PM
pass clientProvider to TestService?
t

Tsvetozar Bonev

10/24/2018, 2:25 PM
Maybe make the TestService a lateinit val and initialize it in an init { } block when you have the cleintProviderInterface available
h

Hexa

10/24/2018, 2:28 PM
thanks can you i tried but got an error saying
late init
modifier is not allowed on primary constructor parameters
can you provide example as I think I may have misunderstood?
t

Tsvetozar Bonev

10/24/2018, 2:30 PM
Oh, sorry, turns out lateinit can't be in the constructor. Why do you need to pass so many things in the constructor though, surely you can build the needed dependency and then pass it
m

Matheus

10/24/2018, 2:31 PM
nah, I re-read the code. i don't think my suggestion would help, as you depend on other stuff to generate the client
h

Hexa

10/24/2018, 2:31 PM
yep I tried passing in the clientProvider to TestService and it didnt work too
I guess my whole Handler class architecture is wrong or what? Maybe there's another way
m

Matheus

10/24/2018, 2:32 PM
but why do you have 2 testServices? can't you use the one you got in the constructor at line 9?
h

Hexa

10/24/2018, 2:32 PM
Ah my mistake
yes the other testService is not needed
I only need the one in the constructor
m

Matheus

10/24/2018, 2:33 PM
ah ok. can you refactor it so the constructor doesn't depend on the client?
t

Tsvetozar Bonev

10/24/2018, 2:33 PM
I don't see why you're passing in the clientProvider as well as the testService
either just pass the provider and build the service inside or build it outside and pass it in
h

Hexa

10/24/2018, 2:38 PM
@Matheus you mean refactor so that I remove this line completely
val testService: TestService = TestServiceImpl(client))
m

Matheus

10/24/2018, 2:40 PM
The problem is that you need a client, which is built on TestHandler's constructor, to build another dependency from TestHandler. So either do that outside this class (build the client and build TestService), or make it so that TestService's constructor doesn't depend on client (maybe the methods could receive a client? can't really say much without seeing the rest of the code).
h

Hexa

10/24/2018, 2:48 PM
okay, just for my understanding if I just not inject
testService
in the constructor. and I use
val testService: TestService = TestServiceImpl(client)
in line 9 that would make my Handler less testable as Im depending on a concrete implementation, is that right? @Matheus
m

Matheus

10/24/2018, 2:49 PM
yes, you wouldn't be able to mock TestService to test this class
View count: 2