array#sample adapted from rubinius
Merge pull request #781 from kostya/sample

array#sample adapted from rubinius