Erik
08/16/2021, 6:10 AMinternal class FooTest
. Why internal
? Are they otherwise published or too accessible somehow?Danish Ansari
08/16/2021, 7:58 AMIntRange
using onEach
function like this
val range = (1..3).onEach { it + 1}
println(range) // expecting 2..4 but still getting 1..3
So what should I try?Jonas Frid
08/16/2021, 1:46 PMcarlos bolanos
08/16/2021, 10:21 PMclass Bar {
baz: String
zab: String
}
class Foo {
attributes: Bar()
}
var foo = Foo()
for(attr in foo.atributes) {
println("$attr")
// baz
// zab
}
I’m looking at using kotlin-reflection lib
and when i use this.condiments::class.members
, i can see the attributes with a bunch of metadata, but i cant get the value.
var foo = Foo()
for(attr in foo.atributes::class.members) {
println("$attr")
// baz
// zab
}
Pitel
08/17/2021, 11:28 AM[A, B, B, B, A, B, B]
(A
and B
are instances of sealed classes). I want to transform it to [[A], [B, B, B], [A], [B, B]]
(so, a list of lists, grouped by classes). How?Richard Gomez
08/17/2021, 1:26 PMDavid Smith
08/17/2021, 4:05 PMBen Woodworth
08/17/2021, 9:43 PMNbtTag
that's implemented by NbtInt
, NbtString
, NbtList<T : NbtTag>
, etc. (for a kotlinx.serialization format library)
NbtList can only contain one type of tag (so T
can't be NbtTag
), and I'm wondering if there's a better way to restrict that. Here's basically what I'm doing right now (which seems overly verbose):
class NbtList<out T : NbtTag> internal constructor(
val content: List<T>
) : NbtTag, List<T> by content
// Pseudo constructors to limit T to concrete types
fun NbtList(content: List<NbtInt>): NbtList<NbtInt> = NbtList<NbtInt>(content)
fun NbtList(content: List<NbtString>): NbtList<NbtString> = NbtList<NbtString>(content)
fun NbtList(content: List<NbtList<*>>): NbtList<NbtList<*>> = NbtList<NbtList<*>>(content)
// plus 9 more for the remaining tag types...
Are there any other ways I can accomplish this and limit the constructor/content?Pablo Schmid
08/17/2021, 10:36 PMdata class MyClass(val person: Person)
. When MyClass is instantiated, it's built with a PersonImpl as the Person is the interface. val result = MyClass(PersonImpl())
I need to dynamically know that the person attribute is a PersonImpl.
I have been trying with `result::class.declaredMemberProperties`but I can't get the PersonImpl from it.
ThanksFlorian
08/18/2021, 9:47 AMList
of objects that each contain an Int
property. What's the most idiomatic way of getting the sum of those `Int`s?
Edit: I think I found it: sumOf
❤️Marc Knaup
08/18/2021, 1:10 PMjava.time
classes or do I have to configure anything for that?Alina Dolgikh [JB]
08/24/2021, 9:00 AMAlina Dolgikh [JB]
08/25/2021, 1:50 PMwhen
statements
• Support for suspend
functions as supertypes
• JS IR compiler in Beta
• Native support for Apple silicon
• And more
Learn more in the blog post.Alina Dolgikh [JB]
10/04/2021, 1:33 PMAlina Dolgikh [JB]
10/19/2021, 1:50 PMhttps://youtu.be/3uVUDsoE_5U▾
Alina Dolgikh [JB]
10/22/2021, 12:44 PMAlina Dolgikh [JB]
10/23/2021, 4:47 PMhhariri
10/24/2021, 5:17 PMAlina Dolgikh [JB]
10/26/2021, 12:05 PMAlina Dolgikh [JB]
11/02/2021, 2:06 PMAlina Dolgikh [JB]
11/03/2021, 1:38 PMAlina Dolgikh [JB]
11/17/2021, 7:19 AMAlina Dolgikh [JB]
12/02/2021, 1:06 PMAlina Dolgikh [JB]
12/03/2021, 4:40 PMbasic tips and tricks▾
solved Day 1▾
Alina Dolgikh [JB]
12/09/2021, 4:07 PMAlina Dolgikh [JB]
12/22/2021, 6:50 PMAlina Dolgikh [JB]
01/11/2022, 2:18 PMAlina Dolgikh [JB]
03/01/2022, 4:39 PMAlina Dolgikh [JB]
04/04/2022, 3:07 PMAlina Dolgikh [JB]
05/05/2022, 2:35 PMmin()
and max()
collection functions
• Stabilizing of definitely non-nullable types
• Updates for the new Kotlin/Native Memory Manager
Read more in the blog post.Alina Dolgikh [JB]
05/05/2022, 2:35 PMmin()
and max()
collection functions
• Stabilizing of definitely non-nullable types
• Updates for the new Kotlin/Native Memory Manager
Read more in the blog post.natario1
05/20/2022, 6:08 PM