Could be a better way of doing it without changing...
# announcements
p
Could be a better way of doing it without changing the signature of the model?
Copy code
fun createDummyProduct(number: Int = 1) = Product(id = "id$number", name = "name$number", title = "title$number")
n
that looks pretty expressive to me already
p
How could I create like a fake Product?
For example, I want this for test purpose
n
isn't that what you're already doing?
p
Yes, but it's not efficient as you said, right?
How could I create like a fake Product given an int or something to be able to create more than one
e
Copy code
with(Product::class.primaryConstructor!!) {
    callBy(parameters.associateWith { "${it.name}$number" })
}
n
val products = List(100) { createDummyProduct(it) }
e
(reflection) not really better and will fail spectacularly under any number of situations
p
Wow, not looking for reflection tbh
e
but if it's just for a test then maybe.
n
sometimes the "you can do that, but it's terrible" answer isn't the best answer ­čśä
e
what do you want, then?
p
I don't know, another way, if it's possible efficient one, because Max said it's "expensive"
n
this seems like it would be fast enough, easily, for any test situation
you could just take a string and use the same string for all three fields
or take an int, create one string from it, and use it for all 3 fields
that would be faster but make it harder to debug potentially...
p
ok thanks guys ­čśä