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

    karelpeeters

    07/10/2017, 11:38 AM
    What happens if you paste it in idea?
    j
    • 2
    • 2
  • d

    diesieben07

    07/10/2017, 11:43 AM
    Honestly, I think that is one of the few bad decisions in Kotlin. Everything is an expression, but not this, because of one obscure bug that IntelliJ will happily warn you about.
    👍 2
    e
    • 2
    • 4
  • a

    arturro

    07/10/2017, 12:09 PM
    Hi Guys! is there a more clean-kotlin-way to write this code:
    if (v1 == null && v2 == null) {
                return 0
            }
            if (v1 != null && v2 == null) {
                return 1
            }
            if (v1 == null && v2 != null) {
                return -1
            }
    d
    c
    a
    • 4
    • 19
  • e

    elect

    07/10/2017, 3:11 PM
    I keep getting
    Exception in thread "main" java.lang.IllegalArgumentException
    on
    @JvmField
    fields
    • 1
    • 1
  • m

    musachy

    07/10/2017, 5:09 PM
    how is property ambiguity resolved? Cant find any info on that
    k
    • 2
    • 1
  • b

    brianwernick

    07/10/2017, 7:58 PM
    Do you have a
    public void setWebSite()
    method?
    d
    • 2
    • 2
  • s

    spand

    07/11/2017, 9:41 AM
    Try
    var members: MutableList<User>? = null
    r
    • 2
    • 1
  • k

    kotlin_questions

    07/12/2017, 2:15 AM
    Can someone help me with kotlinjs? I am trying to follow this tutorial here https://kotlinlang.org/docs/tutorials/javascript/getting-started-idea/getting-started-with-intellij-idea.html i am not getting an "out" folder like it is shown in the example so i am getting a 404 in my browser
    b
    • 2
    • 1
  • m

    maxim

    07/12/2017, 7:35 AM
    Another weird thing I can not reproduce: it worked once to compile from cmd line, I cleaned before, ran "mvn compile" got success, cleaned again, ran compile and it failed. The code itself wasn't changed. Kinda clueless right now
    • 1
    • 1
  • r

    rockerhieu

    07/12/2017, 7:56 AM
    I got these warnings with Kotlin + Proguard:
    Warning: kotlin.internal.JRE8PlatformImplementations: can't find referenced method 'int start(java.lang.String)' in library class java.util.regex.Matcher
    Warning: kotlin.internal.JRE8PlatformImplementations: can't find referenced method 'int end(java.lang.String)' in library class java.util.regex.Matcher
    Warning: kotlin.internal.JRE8PlatformImplementations: can't find referenced method 'java.lang.String group(java.lang.String)' in library class java.util.regex.Matcher
    It seems that this proguard instruction doesn't help:
    -keep class java.util.regex.Matcher { *; }
    i
    • 2
    • 1
  • a

    arturro

    07/13/2017, 2:15 PM
    Hi Guys! Quick question why
    this.javaClass.kotlin
    returns
    KClass<T>
    where
    this::class
    returns
    KClass<out T>
    m
    • 2
    • 1
  • a

    arturro

    07/13/2017, 2:22 PM
    I am asking because I can do that:
    this.javaClass.kotlin.memberProperties.find{ it.name == "test" }!!.get(this)
    but I cannot do that:
    this::class.memberProperties.find{ it.name == "test" }!!.get(this)
            //ErrorKotlin: Out-projected type 'KProperty1<out T, Any?>' prohibits the use of 'public abstract fun get(receiver: T): R defined in kotlin.reflect.KProperty1'
    And I want to understand it
    m
    • 2
    • 2
  • a

    anderson.faro

    07/14/2017, 1:19 AM
    Hey guys, what best blog kotlin for to begin?
    v
    g
    • 3
    • 6
  • k

    karelpeeters

    07/14/2017, 8:58 AM
    To fix this method just replace the
    Any
    with
    T
    .
    t
    m
    • 3
    • 6
  • d

    danneu

    07/14/2017, 12:31 PM
    @karelpeeters btw ended up just changing my interface into an abstract class so that i could make
    internal fun toType(): T
    k
    • 2
    • 1
  • j

    jschneider

    07/14/2017, 4:11 PM
    Hmm. Maybe I messed up the generics. I will try it again
    k
    • 2
    • 6
  • j

    jschneider

    07/15/2017, 3:37 PM
    Ok. Thanks.
    t
    • 2
    • 1
  • k

    kevin.cianfarini

    07/16/2017, 2:23 AM
    I'm just getting started with kotlin...can anyone expain what the
    with
    clause does? Is it similar to python's with?
    v
    • 2
    • 3
  • t

    trevjones

    07/16/2017, 2:48 AM
    it short circuits on the first option. is as expected
    v
    • 2
    • 2
  • e

    erluxman

    07/16/2017, 12:15 PM
    “Kotlin Data Class — My Love at First Sight with Kotlin.” https://medium.com/@erluxman/kotlin-data-class-my-love-at-first-sight-with-kotlin-a83ee8b01670
    👍 1
    v
    • 2
    • 1
  • v

    voddan

    07/16/2017, 7:30 PM
    So that everybody knows: there is a special channel #feed for links to kotlin-related articles. Join it and get new :kotlin: goodness every day! Respectively, if you have wrote a kotlin article, please post a link to it to #feed. Note that #feed is strictly for posting links, any discussion is prohibited there and must be held in other channels.
    👍 1
    g
    n
    • 3
    • 4
  • z

    ziad

    07/16/2017, 8:51 PM
    Hello, does it make sense to add functions to a data class?
    v
    n
    • 3
    • 3
  • z

    ziad

    07/16/2017, 9:24 PM
    So what I had to do was:
    func MyFunction() : String {
       var myReturnVariable : String //Can't seem to get this to be a val
       callTo3rdPartyFunction {
         //Do things
         myReturnVariable = "hello!"
       }
       return myReturnVariable
    }
    g
    • 2
    • 14
  • h

    harmony

    07/16/2017, 11:31 PM
    do you use an ide?
    k
    • 2
    • 1
  • e

    Eugen Martynov

    07/16/2017, 11:58 PM
    I’m getting
    NAME
    has private acceess
    o
    d
    • 3
    • 5
  • o

    oday

    07/17/2017, 2:31 PM
    does that return a map? groupBy?
    a
    j
    • 3
    • 3
  • r

    rockerhieu

    07/18/2017, 4:20 AM
    For example inside an inner class of
    A
    , I can use
    A.this
    v
    • 2
    • 2
  • e

    elect

    07/19/2017, 9:11 AM
    shouldn't this work?
    String.format("#%02X%02X%02X%02X", *i)
    n
    • 2
    • 3
  • d

    diesieben07

    07/19/2017, 9:14 AM
    Kotlin does not (yet) generate Java 8 default methods.
    n
    • 2
    • 4
  • m

    mohita

    07/20/2017, 9:07 AM
    how the for loop in kotlin works? why don't we need to initialize the variable x that iterates in for loop?
    n
    • 2
    • 2
Powered by Linen
Title
m

mohita

07/20/2017, 9:07 AM
how the for loop in kotlin works? why don't we need to initialize the variable x that iterates in for loop?
n

nkiesel

07/20/2017, 8:18 PM
can you give a concrete example that puzzles you? Typical usage would be
for (x in 1..10) println(x)
m

mohita

07/21/2017, 9:44 AM
Yeah. I sorted it out.Just one doubt remaining,if i wanna iterate the for loop not from the beginning,but from say position 5.So how can i do that?
View count: 6