If I say...
a = [1,2,3]
a.shuffle
puts a
...it gives [1,2,3]. If instead I say...
a=[1,2,3]
a.shuffle!
puts a
...it gives me a new order each time I say puts a. So my question is how do I save the order a shuffled array was put into? If it returns [3,1,2] the first time it should keep this order. Does this make sense?
Here is an example of what I'm talking about. Each time I call b I get a different result.
> a=[1,2,3]
=> [1, 2, 3]
> b=a.shuffle!
=> [1, 3, 2]
> b
=> [1, 2, 3]
> b
=> [2, 1, 3]
> b
=> [1, 3, 2]
> b
=> [3, 2, 1]
"b" seems to refer to the function a.shuffle instead of the results of the shuffle itself.
The answer:
The problem occured when using the online interpreter on TryRuby.org. Using the interactive Ruby interpreter on my PC gives the correct result. Thanks to everyone for their help!