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

    martyix

    08/21/2017, 5:31 AM
    Hi, I wrote the following line:
    val command = """{"type":"Modify", "content":{"levels": { "$identifier": {"$propertyName":"$value"}}}}"""
    This is obviously very bad code as any of the variables can easily break JSON. What would be "kotlin-way"? I'm looking for some concise solution. 🙂 Thanks PS: I use Kotlin 1.1.4
    k
    • 2
    • 3
  • d

    diesieben07

    08/21/2017, 11:40 AM
    If the varargs array itself is null, then that's an issue and it's ok if your code throws a NullPointerException, if you document that in the API.
  • k

    karelpeeters

    08/21/2017, 11:43 AM
    You can also check if it's null when calling the method.
    d
    b
    • 3
    • 27
  • l

    leonardootto

    08/21/2017, 1:32 PM
    I need change it to more clear. Do you have some good examples of property extension?
    k
    b
    • 3
    • 7
  • r

    rsteiger

    08/21/2017, 10:58 PM
    So, I'd really appreciate a minimalist idiot's guide to how you'd create the ktor Getting Started project (the ktor docs assume you're an IJ Master Jedi :-).
    v
    • 2
    • 2
  • r

    rsteiger

    08/21/2017, 11:00 PM
    BTW, I'm faced with the same ignorance just trying to run through the koans ...
    k
    p
    k
    • 4
    • 9
  • l

    longthanhtran

    08/22/2017, 12:13 PM
    hi, I am starting with Kotlin and trying to find Sublime text 3 syntax highlight plugin for kotlin but seems there is yet one ?
    k
    d
    e
    • 4
    • 15
  • m

    Michael

    08/22/2017, 2:39 PM
    Hey folks! Trying to integrate kotlin in an existing maven project here. I did so just fine following the instructions on the website using maven/intellij - it’s building fine, and it’s running in the editor for me. But my teammates on eclipse aren’t having any luck (nor am I, if I fire it up in eclipse.) Added the Kotlin Plugin for Eclipse - but it seems that it’s not delegating to maven to actually run the compilation. Any suggestions?
    v
    e
    • 3
    • 6
  • k

    karelpeeters

    08/23/2017, 6:09 PM
    @ilya.gorbunov?
    i
    l
    • 3
    • 11
  • m

    mfiano

    08/24/2017, 3:23 AM
    Is Kotlin easy to learn with no Java or C-like language experience? Only language I know is Common Lisp.
    v
    b
    +3
    • 6
    • 17
  • t

    tipsy

    08/24/2017, 11:37 AM
    what is usually used for random id's in kotlin? just
    UUID.randomUUID()
    ?
    k
    d
    • 3
    • 2
  • k

    kagomez

    08/25/2017, 12:09 AM
    hey guys a question; is there a best practice for a classs that has multiple constructors?
    a
    • 2
    • 2
  • m

    muralimohan962

    08/26/2017, 8:25 AM
    How to compile and run both java and kotlin files together from the command line?
    v
    • 2
    • 1
  • b

    baob

    08/26/2017, 9:30 PM
    I’m a total newb to kotlin, (and java too pretty much) but I find to get started I need to make a choice between maven and gradle. Based on reading this I’m thinking for a beginner, and small projects, that Maven might be good for me ? What do you think ? https://dzone.com/articles/maven-vs-gradle-and-the-best-of-both-worlds
    x
    m
    +2
    • 5
    • 5
  • b

    baob

    08/27/2017, 11:48 AM
    I’ve been hacking away with attempts like
    sourceSets.main.kotlin.srcDirs = ['src']
    but even that doesn’t seem to do it
    x
    r
    • 3
    • 7
  • d

    dancancro

    08/27/2017, 6:27 PM
    Hi everyone. I am brand new to Kotlin and having the following problem with my JHipster app in which I mix java and kotlin: https://github.com/dancancro/great-big-example-application/tree/blogwithkotlin/src/main/kotlin/org/exampleapps/greatbig
    2017-08-27 14:12:33.623  WARN 62423 --- [  XNIO-2 task-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.VerifyError: Uninitialized object exists on backward branch 82
    Exception Details:
      Location:
        org/exampleapps/greatbig/domain/inout/Article$Companion.fromModel(Lorg/exampleapps/greatbig/domain/Article;Lorg/exampleapps/greatbig/domain/Author;)Lorg/exampleapps/greatbig/domain/inout/Article; @129: goto
      Reason:
        Error exists in the bytecode
      Bytecode:
        0000000: 2b12 39b8 000f 2c12 3bb8 000f bb00 3d59
        0000010: 2bb6 0043 2bb6 0046 2bb6 0049 2bb6 004c
        0000020: 2bb6 0050 c000 524e 3a12 3a11 3a10 3a0f
        0000030: 3a0e 3a0d 2d3a 04bb 0054 592d 100a b800
        0000040: 5ab7 005e c000 603a 0519 04b9 0064 0100
        0000050: 3a06 1906 b900 6a01 0099 002b 1906 b900
        0000060: 6e01 003a 0719 0519 07c0 0070 3a08 3a13
        0000070: 1908 b600 733a 1419 1319 14b9 0077 0200
        0000080: 57a7 ffd1 1905 c000 793a 1319 0d19 0e19
        0000090: 0f19 1019 1119 1219 132a c000 022b b600
        00000a0: 7db6 007f 2ac0 0002 2bb6 0082 b600 7fb2
        00000b0: 0088 2bb6 008c 2cb6 0092 2bb6 0095 2cb9
        00000c0: 0098 0200 2bb6 0095 b900 9c01 003e 3604
        00000d0: 3a05 3a06 3a07 3a08 3a09 3a0a 3a0b 3a0c
        00000e0: 190b 190a 1909 1908 190c 1907 1906 1905
        00000f0: 1504 1db7 009f b0
      Stackmap Table:
        full_frame(@82,{Object[#2],Object[#63],Object[#176],Object[#82],Object[#82],Object[#96],Object[#102],Top,Top,Top,Top,Top,Top,Uninitialized[#12],Uninitialized[#12],Object[#178],Object[#178],Object[#178],Object[#178]},{})
        same_frame(@132)
    o
    • 2
    • 20
  • d

    d.medina

    08/27/2017, 8:42 PM
    object AppDataManager : DataManager by dataManager {
      private lateinit var dataManager: DataManager
      fun init(manager: DataManager) {
        dataManager = manager
      }
    r
    • 2
    • 2
  • b

    baob

    08/27/2017, 10:17 PM
    On the remote chance that anyone is trying to replicate the example ktor app (as a complete kotlin/java newb, as I was) then you’ll find the steps to doing that by following this branch in my repo. https://github.com/baob/sandbox-kotlin-ktor-hello/tree/gradle-hacked-from-ktor-readme-improved /cc @rocketraman @x80486
    o
    • 2
    • 2
  • j

    jtonic

    08/28/2017, 4:37 AM
    Dear Kotlin community, Is it possible to convert the following java annotations to kotlin? I tried to make it w/o any luck. I thought @JvmField would be of any help, but wasn’t.
    public class Profiles {
    
      @Target(ElementType.TYPE)
      @Retention(RetentionPolicy.RUNTIME)
      @Profile(Service1MockedProfile.NAME)
      public @interface Service1MockedProfile {
    
        String NAME = “Service1MockedProfile”;
      }
    
      @Target(ElementType.TYPE)
      @Retention(RetentionPolicy.RUNTIME)
      @Profile(Service2MockedProfile.NAME)
      @interface Service2MockedProfile {
    
        String NAME = “Service2MockedProfile”;
      }
    }
    
    @Service
    @Profiles.Service1MockedProfile
    class MyService {}
    
    @ActiveProfiles(profiles = {Service1MockedProfile.NAME})
    class MyServiceTest {}
    o
    • 2
    • 3
  • f

    f.babic

    08/28/2017, 11:57 AM
    Hey guys, in case anyone here is just getting started with Kotlin (as the channel name suggests! 😄 ) I’ve got a mini series of articles about Kotlin that I’ve been writing in my spare time to spread the word around about the awesome language all of us use every day 🙂 So in case any of my current and future articles help you, it would mean a lot to me. https://medium.cobeisfresh.com/kotlin-fever-part-2-functions-and-expressions-f93dba724298 Also, any criticism, no matter if positive, negative, constructive, or just random is welcomed ❤️
    👍 3
    k
    • 2
    • 1
  • j

    jtonic

    08/28/2017, 6:17 PM
    Hi, Is it possible to have a public static final field in kotlin annotation like we can have in java? I tried to use the @JvmField but w/o any luck. It works fine on object but it seems not to work in kotlin. Java code
    @Target(ElementType.TYPE)
     @Retention(RetentionPolicy.RUNTIME)
     @Profile(Service1MockedProfile.NAME)
     public @interface Service1MockedProfile {
    
       String NAME = "Service1MockedProfile";
     }
    During the migration from Java to Kotlin this is one of the remaining code that still struggling with.
    v
    • 2
    • 1
  • k

    karelpeeters

    08/28/2017, 6:30 PM
    Maybe file an issue about this?
    j
    • 2
    • 1
  • a

    agomez

    08/29/2017, 4:47 PM
    https://medium.com/100-free-udemy-coupons/the-total-kotlin-course-learn-kotlin-today-udemy-free-coupon-100-off-ea6e89c86575
    k
    • 2
    • 2
  • s

    Slackbot

    08/29/2017, 8:30 PM
    This message was deleted.
    k
    d
    • 3
    • 2
  • s

    saurabha5

    08/30/2017, 3:13 PM
    What is the best way to Deal with HTTP calls on Android with Kotlin ? Do I really need to use an external library or something comes along with Kotlin ?
    o
    t
    • 3
    • 2
  • p

    poohbar

    08/30/2017, 3:14 PM
    wait why would methods be in the variables list during debugging???
    a
    • 2
    • 5
  • a

    amichalski

    08/30/2017, 3:38 PM
    Are there any good dependency injection framework except Dagger 2 for Kotlin in Android?
    a
    j
    t
    • 4
    • 6
  • h

    halirutan

    08/30/2017, 10:42 PM
    Here is a beginners question. In java one sometimes uses
    interface
    to hold data-values
    public interface SymbolNames {
      String BeginPackage = "BeginPackage";
      String EndPackage = "EndPackage";
      String End = "End";
    }
    What is the equivalent in Kotlin? When I convert the above to Kotlin it gives me an interface with a companion object. Is this the way to go?
    k
    • 2
    • 5
  • t

    techie01

    08/31/2017, 7:47 AM
    how to work with datetime in kotlin with java support
    k
    • 2
    • 2
  • a

    arekolek

    08/31/2017, 9:55 AM
    How come does
    run
    work with references that accept an argument, even though it’s defined as
    T.run(block: T.() -> R): R = block()
    ?
    i
    • 2
    • 3
Powered by Linen
Title
a

arekolek

08/31/2017, 9:55 AM
How come does
run
work with references that accept an argument, even though it’s defined as
T.run(block: T.() -> R): R = block()
?
i

ilya.gorbunov

08/31/2017, 4:15 PM
The functional types
(T) -> R
and
T.() -> R
are assignment compatible.
🙀 1
➕ 2
a

arekolek

08/31/2017, 4:22 PM
Thanks, any place where one can read more about that?
i

ilya.gorbunov

08/31/2017, 4:42 PM
Can't find anything about it. Probably the function types http://kotlinlang.org/docs/reference/lambdas.html#function-types section should be extended.
View count: 4