Let\'s say I want to access an element of an array at a random index this way:
[1, 2, 3, 4].at(rand(4))
Is there a way to pass the size of
You could do something similar with lambda:
getrand = ->(x) { x[rand(x.count)] } getrand.call [1,2,3] # => 2