1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

rand: minor cleanup in choose() (#14376)

This commit is contained in:
yuyi 2022-05-12 16:20:38 +08:00 committed by GitHub
parent 5bc4fea9e0
commit 8830af5c89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -327,9 +327,7 @@ pub fn (mut rng PRNG) choose<T>(array []T, k int) ?[]T {
}
mut results := []T{len: k}
mut indices := []int{len: n, init: it}
// TODO: see why exactly it is necessary to enfoce the type here in Checker.infer_fn_generic_types
// (v errors with: `inferred generic type T is ambiguous: got int, expected string`, when <int> is missing)
rng.shuffle<int>(mut indices) ?
rng.shuffle(mut indices) ?
for i in 0 .. k {
results[i] = array[indices[i]]
}