Following this simple but very convenient method to sample from an array without replacement, we can see something like
arr = ["a", "b", "c", "d", "e", "f"]
arr.sample(10)
=> ["b", "a", "d", "f", "e", "c"]
How is same accomplished, but with replacement? So in the example .sample(10)
would return an array of length 10 with some duplicate elements?
e.g.
arr = ["a", "b", "c", "d", "e", "f"]
arr.sample(10)
=> ["b", "a", "d", "f", "e", "c", "b", "e", "a", "b"]