Random Numbers

Hi dear broot
I have tried new algorithm that kind of does the same as yours.here is it:
var i = 0
while (i <= 9) {
var n = Random.nextInt(1, 11)
var find = 0
for (j in 0…9) {
if (myarray[j] == n) {
find = 1
break
}
}
if (find == 0) {
myarray[i] = n
++i
}
}
myarray.forEach {
print("$it ")
}
I know it has more code lines compare to yours,but I would appreciate if you let me know about the CONS on this one.
*****BTW I have just began learning *Collections which the im on the very first topic that is “listOf”
so im working on it and will try to write the code using your advice(operiting random numbers in a List)
thank you so much again man,I really appreciate the way you care and dedicate your valuable time for helping me.