Rui
04/18/2025, 7:43 PMcarbaj0
04/19/2025, 5:18 AMالخبرات العلمية ScienceExperts
04/20/2025, 8:56 PMNick
04/21/2025, 12:04 PMEdgar Avuzi
04/21/2025, 4:05 PMSlackbot
04/21/2025, 4:19 PMy
04/22/2025, 12:56 PMfor
loop over a List
, have equivalent performance to using subList()
?Alex
04/25/2025, 12:42 PMOleg Smirnov
04/26/2025, 6:23 PMFrancesc
04/27/2025, 9:21 PMcontext 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 confirmPratyush
04/29/2025, 6:07 AMdirk.dittert
04/29/2025, 8:37 AMdata 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:
/**
* 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?y
04/30/2025, 11:18 AMelse
case for single-expressions, for brevity/syntax-sugar? for example
if (something) {
do_thing()
} else when (somethingElse) {
A -> a()
B -> b()
C -> c()
}
Youssef Shoaib [MOD]
04/30/2025, 8:55 PMMichael de Kaste
05/01/2025, 8:22 AMdata 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)
}
maarten ha
05/01/2025, 10:34 AMShaun Wild
05/01/2025, 7:49 PMKlitos Kyriacou
05/02/2025, 2:41 PM@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
.JP Sugarbroad
05/02/2025, 9:53 PMopen class Super
class Container<T: Super>
fun test(thing: Any) {
if (thing is Container<*>) {
val thing2 = thing as Container<Super>
}
}
But this does not?
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?y
05/07/2025, 4:34 AMUInt
?
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.Carsten Hagemann
05/08/2025, 9:33 AMSean Graham
05/08/2025, 1:35 PMDwayne Keane
05/09/2025, 7:39 PMVinicius
05/09/2025, 9:18 PMy
05/11/2025, 7:31 AMclass 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.CLOVIS
05/11/2025, 9:01 AMreturn Unit.INSTANCE;
at the end of each lambda is quite versbose.carbaj0
05/12/2025, 6:09 AMhfhbd
05/12/2025, 3:06 PMAtul Kumar
05/13/2025, 4:10 AMy
05/13/2025, 5:09 AMif let
in Rust and Swift), what's your favorite way of expressing this in Kotlin?
1. with scope functions:
parseData(data)?.also { /* ... */ }
2. with flow-sensitive typing:
val parsed = parseData(data)
if (parsed != null) { /* ... */ }
3. some other way?
1
feels more idiomatic but not quite first-class.