Newbie here. Thanks in advance.
The idea here is akin to pulling a card at random from a deck of cards. I want to permanently pull a random number out of the array.
My code is giving me an error regarding the 'delete!' method. "Undefined method delete!' for [1, 2, 3, 4, 5, 6, 7, 8]:Array
(repl):6:ininitialize'". But for all I know there might be half a dozen errors in here.
I've commented the code below so you can follow my amateur thought process. I'm sure there's some awesome way to write this all in two lines of code that I just haven't experienced yet. Can you help?
array = [1, 2, 3, 4, 5, 6, 7, 8]
# Create array of sequential numbers
high_number = array.length - 1
# Determining length of array for next line, offset by 1 for array
rand_number = rand(0..high_number)
# Create a random number from 0 (first array position) through high num
draw = array[rand_number]
# drawing that position number from array (passed on to another action)
array.delete!(rand_number)
# make sure the next time I loop through this array that number can't be drawn again