In Ruby, how would I select a random element from one array and combine it with a randomly selected element from a second array?
For example if I have the arrays:
array1 = ["x", "y", "z"]
array2 = ["a", "b", "c"]
I'm looking for the output to be (array1_element)(array2_element)(array1_element) like xby or ycz or xbx so on and so forth. Can Ruby's .sample method be used on multiple arrays to print out a single string?
Aucun commentaire:
Enregistrer un commentaire