Last active
June 12, 2018 14:48
-
-
Save brandonhilkert/7848392 to your computer and use it in GitHub Desktop.
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
class MegaLotto | |
NUMBERS = 5 | |
def draw | |
NUMBERS.times.inject([]) do |arr, i| | |
arr << single_draw | |
end | |
end | |
private | |
def single_draw | |
rand(0...60) | |
end | |
end | |
MegaLotto.new.draw # => [23, 22, 3, 7, 16] |
Ha! Thanks for all the feedback. Sorry for the typos...I originally wrote this for something else, so the class/method names were a little off.
The point of the course was not about the code (I think I mentioned that in the course). Feel free to write whatever code you like. I can't imagine this code being very useful anyway, so hopefully you're writing something that you'll benefit from. I wanted to get something down to discuss the structure and use of a gem, but again, feel free to use whatever code you like.
If you prefer your implementation of the code, feel free to use it.
sounds good to me. looking froward for next session of course 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Guys, this is about writing a gem, not about writing the bestest ever random lottery number generator. other than the few typos, the focus is on the ability to write a gem not a generator.