-
-
Save ferski/d36be0177ba37fc0c258 to your computer and use it in GitHub Desktop.
Not Understanding Values inside classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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