This file contains hidden or 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
| def smiley(hash) | |
| myhash = {"happy" => ":)"} | |
| hash.each do |key, value| | |
| end | |
| myhash["happy"] | |
| end |
This file contains hidden or 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
| def smiley(hash) | |
| myhash = {"happy" => ":)"} | |
| hash.each do |key, value| | |
| myhash[value] | |
| end | |
| end |
This file contains hidden or 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
| class Die | |
| attr_accessor :faces | |
| def initialize(faces) | |
| @faces = faces | |
| end | |
| def sides | |
| @faces | |
| end | |
| def roll | |
| (1..@faces).to_a.sample |
This file contains hidden or 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
| class Die | |
| attr_accessor :faces | |
| def initialize(faces) | |
| @faces = faces | |
| end | |
| def sides | |
| @faces | |
| end | |
| def roll | |
| self.rand(1..6) |
NewerOlder