Skip to content

Instantly share code, notes, and snippets.

@mfpiccolo
Created January 24, 2013 05:33
Show Gist options
  • Save mfpiccolo/4617922 to your computer and use it in GitHub Desktop.
Save mfpiccolo/4617922 to your computer and use it in GitHub Desktop.
my_dice.roll will give you a random number from one to six. to change the number of sides change the argument in Die.new()
class Die
attr_accessor :sides
def initialize(number)
@number = number
end
def roll
rand(1..@number)
end
end
my_dice = Die.new(6)
puts my_dice.roll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment