https://kotlinlang.org logo
Join SlackCommunities
Powered by
# getting-started
  • r

    Rui

    04/18/2025, 7:43 PM
    Hi guys I’m new here, is there still a way to join this summer’s GSoC?
    👋 1
    kodee welcoming 1
    s
    • 2
    • 1
  • c

    carbaj0

    04/19/2025, 5:18 AM
    If I'm not mistaken, this should work.
    🚫 1
    y
    p
    +3
    • 6
    • 13
  • u

    الخبرات العلمية ScienceExperts

    04/20/2025, 8:56 PM
    for beginners should they learn XML or start with jet compose ?
    y
    r
    +2
    • 5
    • 4
  • n

    Nick

    04/21/2025, 12:04 PM
    Hi, I need some guidance. I am on Windows 11. I downloaded kotlinc from the Github. I downloaded IntelliJ IDEA with Education License. My aim is to make a skill file for the furhat robot. I am not sure what to do. I wrote a hello world yesterday and the .kt file worked. Need some guidance and point of contact. Can anyone help?
    r
    • 2
    • 1
  • e

    Edgar Avuzi

    04/21/2025, 4:05 PM
    Following the article https://kt.academy/article/ek-platform-types Summary section > Types that come from another language and have unknown nullability are known as platform types. > Since they are dangerous, we should eliminate them as soon as possible and not let them propagate. > It is also good to specify types using annotations that specify nullability for exposed Java constructors, methods and fields. > This is precious information for Java and Kotlin developers who use these elements. specifically > Since they are dangerous, we should eliminate them as soon as possible and not let them propagate. How can one enforce — perhaps during build time — that any Java platform type must be explicitly resolved at the first point of Java ↔️ Kotlin interaction, so that no platform types leak deeper into the Kotlin codebase? Without modifying the Java code
    e
    m
    • 3
    • 3
  • s

    Slackbot

    04/21/2025, 4:19 PM
    This message was deleted.
    m
    y
    • 3
    • 5
  • y

    y

    04/22/2025, 12:56 PM
    does an index-based
    for
    loop over a
    List
    , have equivalent performance to using
    subList()
    ?
    p
    e
    • 3
    • 5
  • a

    Alex

    04/25/2025, 12:42 PM
    I’ve started a new project and wanted to use jOOQ, everything kind of worked until I wanted to add autogenerated classes. I’m getting such weird errors and I can’t for the life of dog me figure out what I’m doing wrong. I’m using the latest versions of packages, their builds seem to pass and the docs also state that everything should work together nicely but it doesn’t. And the errors are so… seemingly simple that Claude is also no help. 🥲 Anybody have experience with jOOQ code gen with a gradle plugin?
    k
    e
    • 3
    • 17
  • o

    Oleg Smirnov

    04/26/2025, 6:23 PM
    Hello, everyone! Could you please suggest a kotlin library that is a wrapper for the GitHub API? Maybe something you use yourself or heard about. Would much appreciate any suggestions! Thank you in advance.
    v
    • 2
    • 1
  • f

    Francesc

    04/27/2025, 9:21 PM
    when using
    context parameters
    , do all intermediate functions need to declare them, even if only the last function in the stack accessed them? I have a sample in thread where that seems to be the case as it won't compile otherwise, but I'd like to confirm
    y
    j
    +2
    • 5
    • 8
  • p

    Pratyush

    04/29/2025, 6:07 AM
    Hey Folks, I am facing a weird issue with my IntelliJ CE. When i switch between screens on my Mac, the project folder collapes, the open files close and git history is not visible. sad panda I have tried reinstalling the ide but nothing changed. ide version: 2025.1
    not kotlin but kotlin colored 5
  • d

    dirk.dittert

    04/29/2025, 8:37 AM
    I am still having trouble with the expressiveness of Kotlin when it comes to constructors. Here is a simplified example. There is a data class that should store the names of columns in CSV files. However, we want those to always be in uppercase. I guess, this would be a solution for that:
    Copy code
    data class Column(
        private val _csvName: String,    
        val someOtherInfo: SomeInfo) {    
        
        val csvName: String = _csvName.uppercase()    
        
        init {
        	if (!csvName.startsWith("A")) {            
        		throw IllegalArgumentException("Noooo!")        
        }       
    }
    How do you properly write documentation for that without scattering the information in several places? After all
    _csvName
    is just a technical artifact that is required due to Kotlin's syntax. Here is what I mean:
    Copy code
    /**
     * Some Explanation
     *
     * @param _csvName placeholder to be able to transform the name to uppercase. See following description of [csvName]
     * @param someOtherInfo Some other flags.
     */
    data class Column(
    How do you handle something like that in your projects?
    h
    c
    m
    • 4
    • 12
  • y

    y

    04/30/2025, 11:18 AM
    is it weird/unidiomatic to omit the braces in an
    else
    case for single-expressions, for brevity/syntax-sugar? for example
    Copy code
    if (something) {
      do_thing()
    } else when (somethingElse) {
      A -> a()
      B -> b()
      C -> c()
    }
    r
    y
    +2
    • 5
    • 25
  • y

    Youssef Shoaib [MOD]

    04/30/2025, 8:55 PM
    1) anyone know of a multiplatform WeakHashMap implementation? 2) just checking, if the key used for some entry in a WeakHashMap gets GCed, does the corresponding value become eligible for GC too? As in, I need the value to live while the key is alive, but when the key dies, and no one else refers to the value, I want the value to die.
    e
    • 2
    • 3
  • m

    Michael de Kaste

    05/01/2025, 8:22 AM
    is there a reason why guards cannot infer nullability based on previous checked values? Or is my IDE not understanding correctly? (I have when guards on and K2 compiler selected, it only complains about type inference)
    Copy code
    data class Request(
        val type: Type
    	val value: String?
    )
    
    enum class Type { A, B }
    
    data class A(val value: String)
    data class B(val value: String?)
    
    fun Request.toDto() = when(type){
        Type.A if value == null -> throw ApiValidationException("value has to be filled when type is A")
    	Type.A -> A(value) // <-- Cannot infer value being non-null
        Type.B -> B(value)
    }
    d
    • 2
    • 1
  • m

    maarten ha

    05/01/2025, 10:34 AM
    I’m currently working on a Kotlin project and want to setup linting. I have never setup any linting before and was wondering if there are any suggestions. Linting in Typescript is not new to me but in Kotlin it is. Currently I’m looking at ktlint and detekt to see what might be the nicest to use
    s
    s
    • 3
    • 2
  • s

    Shaun Wild

    05/01/2025, 7:49 PM
    How do I enable the code inspection that allows you to move a gradle dependency to the version catalog? I remember it being a thing and now I can't access it.
    m
    • 2
    • 2
  • k

    Klitos Kyriacou

    05/02/2025, 2:41 PM
    If I use the
    @Language
    annotation, will my project be able to be compiled by those using VSCode? I'm unsure because it's in a package that starts with
    org.intellij
    .
    h
    j
    • 3
    • 3
  • j

    JP Sugarbroad

    05/02/2025, 9:53 PM
    Why does this produce a warning:
    Copy code
    open class Super
    
    class Container<T: Super>
    
    fun test(thing: Any) {
        if (thing is Container<*>) {
            val thing2 = thing as Container<Super>
        }
    }
    But this does not?
    Copy code
    open class Super
    
    class Container<T: Super>
    
    fun test(thing: Any) {
        if (thing is Container<out Super>) {
            val thing2 = thing as Container<Super>
        }
    }
    Shouldn't
    *
    be equivalent to
    out Super
    in this case?
    l
    s
    • 3
    • 13
  • y

    y

    05/07/2025, 4:34 AM
    is it idiomatic to just not use
    UInt
    ? typically in a strongly-typed language you would use an unsigned type for validation, but everything ever takes
    Int
    (for "Java reasons" which I do understand) so there's going to be conversions at the call site everywhere.
    y
    k
    • 3
    • 7
  • c

    Carsten Hagemann

    05/08/2025, 9:33 AM
    Hello, my team wants to develop a KMP library, so that we only have to write the business/API-interacting code once. That's set. But we don't know whether to • Only expose a KMP library for AND and iOS targets • Or to have an internal KMP library + then an additional "wrapper" library for iOS, so that iOS library consumers don't have to care/know that we are using a KMP library with all that it entails (maybe using SKIE?). What is usually recommended to do in this case?
    • 1
    • 1
  • s

    Sean Graham

    05/08/2025, 1:35 PM
    I studying junior software development is there remote jobs
    v
    • 2
    • 1
  • d

    Dwayne Keane

    05/09/2025, 7:39 PM
    May I know where the best place is to start learning app development? Any resource someone can recommend? One that is considered wholesome that is.
  • v

    Vinicius

    05/09/2025, 9:18 PM
    I just wanted to say, whoever was in charge of designing the Duration API should be ashamed of themselves.
    🚫 1
    🧌 4
    🧐 1
    ❓ 8
    💩 1
    p
    k
    +2
    • 5
    • 4
  • y

    y

    05/11/2025, 7:31 AM
    given
    Copy code
    class Foo {
      class Bar { 
        class Baz : Bar()
      }
    
      fun Bar.Baz.funName() { /* ... */ }
    }
    this
    or
    this@Baz
    can be used to refer to the
    Baz
    (and
    this@Foo
    is used to refer to the parent) however
    this@funName
    can also be used for
    Baz
    , what's the rationale here? that's kind of strange.
    j
    • 2
    • 2
  • c

    CLOVIS

    05/11/2025, 9:01 AM
    What are your strategies for exposing Kotlin DSLs for Java users? The explicit
    return Unit.INSTANCE;
    at the end of each lambda is quite versbose.
    k
    • 2
    • 2
  • c

    carbaj0

    05/12/2025, 6:09 AM
    I can´t build any iOS app because 🧵 Kotlin 2.2.0-Beta2 and compose multiplatform 1.8.0
    r
    • 2
    • 2
  • h

    hfhbd

    05/12/2025, 3:06 PM
    I want to use context parameters to scope an existing Kotlin DSL. According to the KEEP, this should be supported, but I failed to create the functions.
    y
    • 2
    • 6
  • a

    Atul Kumar

    05/13/2025, 4:10 AM
    I am working on a Application in KMM, please suggest any good resource how to use same viewModel in android and in IOS where UI component are to shared with each other
  • y

    y

    05/13/2025, 5:09 AM
    for people who come from languages with pattern-matching conditional statements (for example,
    if let
    in Rust and Swift), what's your favorite way of expressing this in Kotlin? 1. with scope functions:
    Copy code
    parseData(data)?.also { /* ... */ }
    2. with flow-sensitive typing:
    Copy code
    val parsed = parseData(data)
    if (parsed != null) { /* ... */ }
    3. some other way?
    1
    feels more idiomatic but not quite first-class.