Search code examples
rubydirectiondice

Making a dice in ruby language


Im coding a dice in ruby in which when i rolled it, it would either come up north south east or west.

what im having trouble with is when i roll it how do i tell it to return to me one of these directions?

any help would be great.


Solution

  • Use Array.sample:

    [ 'north', 'south', 'east', 'west' ].sample