<commit_before>[Week 5 Home](../)

# U2.W5: Die Class 2: Arbitrary Symbols


## Learning Objectives
- Break down problems into implementable pseudocode 
- Implement a basic Ruby class and identify when to use instance variables
- Use if/else statements, string methods, while/until loops, Enumerable#each methods
- Find and use built-in Ruby methods to solve challenges

## Background
Working off your previous `Die` class from [Die Class 1](http://socrates.devbootcamp.com/exercises/46), implement a new `Die` class which takes an array of strings as its input.  When `Die#roll` is called, it randomly returns one of these strings.  If `Die.new` is passed an empty array, raise an `ArgumentError`.  It should work like this:

```ruby
die = Die.new(['A', 'B', 'C', 'D', 'E', 'F'])
die.sides # still returns the number of sides, in this case 6
die.roll # returns one of ['A', 'B', 'C', 'D', 'E', 'F'], randomly
```

Just to reiterate, in the previous exercise you passed in a number of sides, `sides`, and the labels were assumed to be the integers `1..sides`.  Now we're passing in a list of arbitrary labels.  We could use this to represent a [Dreidel](http://en.wikipedia.org/wiki/Dreidel) or [Boggle dice](http://en.wikipedia.org/wiki/Boggle), for example.<commit_msg>updated link to die class 1<commit_after>[Week 5 Home](../)

# U2.W5: Die Class 2: Arbitrary Symbols


## Learning Objectives
- Break down problems into implementable pseudocode 
- Implement a basic Ruby class and identify when to use instance variables
- Use if/else statements, string methods, while/until loops, Enumerable#each methods
- Find and use built-in Ruby methods to solve challenges

## Background
Working off your previous `Die` class from [Die Class 1](../1_die), implement a new `Die` class which takes an array of strings as its input.  When `Die#roll` is called, it randomly returns one of these strings.  If `Die.new` is passed an empty array, raise an `ArgumentError`.  It should work like this:

```ruby
die = Die.new(['A', 'B', 'C', 'D', 'E', 'F'])
die.sides # still returns the number of sides, in this case 6
die.roll # returns one of ['A', 'B', 'C', 'D', 'E', 'F'], randomly
```

Just to reiterate, in the previous exercise you passed in a number of sides, `sides`, and the labels were assumed to be the integers `1..sides`.  Now we're passing in a list of arbitrary labels.  We could use this to represent a [Dreidel](http://en.wikipedia.org/wiki/Dreidel) or [Boggle dice](http://en.wikipedia.org/wiki/Boggle), for example.
{'fraction_non_alphanumeric': 0.11666666666666667, 'fraction_numerical': 0.007142857142857143, 'mean_word_length': 4.263048016701461, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6307808', 'n_tokens_mistral': 760, 'n_tokens_neox': 728, 'n_words': 354}