I am struggling to write a clean method which when passed an array of strings and x returns a randomised list of array elements totalling x, eg.
def getrandomarrayelements(thearray, howmany)
return [something]
end
Yes I should submit my existing code, which whilst works is not good, it’s 8 lines long and I have a feeling it can be done in one?!
In ruby 1.9:
and for ruby 1.8 something like this: