hey guys, what is the equavilant of this python co...
# getting-started
a
hey guys, what is the equavilant of this python code
Copy code
s = "string"
list = [s * 10]
basically, I just want to create a list of objects each of them is the same string actually
j
Probably:
Copy code
val list = List(10) { "string" }
This
List
factory function takes a desired size and a lambda. The lambda is called
size
times with an element index as argument (ignored here), and it should return the desired value for the element at that index
👌 2
a
Perfect! thanks a lot
k
By the way, you probably meant
[s]*10