https://kotlinlang.org logo
#getting-started
Title
# getting-started
m

Max Deineko

01/05/2021, 3:10 PM
Hi, I'm trying (and so far failing) to understand why evaluating the following code in a scratch file in idea results in unexpected (for me) output:
Copy code
val l = mutableListOf("a")
l[0] = "b"
val x = l.first()
println("""$x=${l.first()}""")
Copy code
val l: MutableList<String>

val x: String
a=b
When evaluated with "Use REPL" or via run command from the menu it prints "b=b" instead. Am I missing something or is this a bug? (If this is too intellij-specific and not getting-started-related enough, I'll be happy to move this to #intellij)
d

Dmitry

01/05/2021, 3:19 PM
It’s definitely is an unexpected result. IntelliJ scratch is showing incorrect result. Looks like a bug in Kotlin plugin for IntelliJ, that evaluates scratch file. I would suggest opening ticket
👍 1
m

Max Deineko

01/05/2021, 4:05 PM
Thanks for confirmation! Somehow my quick scan of issues failed to turn up these prior -- now I see this seems to be a known¹ bug². ¹ https://youtrack.jetbrains.com/issue/KT-30479 ² https://youtrack.jetbrains.com/issue/KT-35512
3 Views