Skip to content

Instantly share code, notes, and snippets.

@ferski
Last active August 29, 2015 14:04
Show Gist options
  • Save ferski/d36be0177ba37fc0c258 to your computer and use it in GitHub Desktop.
Save ferski/d36be0177ba37fc0c258 to your computer and use it in GitHub Desktop.
Not Understanding Values inside classes
9 class DiceSet
10 attr_accessor :values
11 def initialize()
12 @values = Array.new
13 end
14 def roll(dices)
15 @values.clear
16 dices.times do |i|
17 @values << 1 + rand(6)
18 end
19 end
20 end
...
49 dice.roll(5)
50 first_time = dice.values
51 dice.roll(5)
52 second_time = dice.values
53 assert_not_equal first_time, second_time,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment