Hi! I’m trying to write a program that will print out a different
string each time it’s run from a list of strings.
For example:
example = [‘one’, ‘two’, ‘three’]
sort them somehow
‘two’ prints out as the output, for example
run it again and a different string prints out
Make sense? I’ve tried srand & rand but can’t do this with strings. Do
I need to forget the arrays and try something else? I’ve looked at the
Pickaxe book and Ruby Cookbook but can’t find anything. Thanks!
Well James is the “boss” of the quiz, but the ML and the Quiz are two
distinct matters.
I personally chose to try to avoid to post any material too much related
to
the Quiz and furthermore I point it out to others who might not be
interested in the Quiz.
Quizzes can be spoiled by posts of course, I redrew a quiz once because
the
issue was discussed three days before its due date, actually I think it
was
a good thing because after the discussion I did not think my Quiz was
very
brilliant any more:). James was just great he had another quiz to come
up
with immediately.
AFAIAC your reply has been very thoughtful, do not worry!
Cheers
Robert
P.S. Quiz Advocacy, checking the quiz is a good idea anyway :)))
This is not really what you want to do but I cannot post more for now,
this is a Ruby Q. Spoiler!!!
Robert
Ok time to clarify. #sort_by{ rand } is fine, it is my head that is broken, so it is time
for
me to apologize #sort{ rand } of course is not, but I’ll get new reading glasses soon.
I personally chose to try to avoid to post any material too much
related to
the Quiz and furthermore I point it out to others who might not be
interested in the Quiz.
Overlap happens. No big deal. It just means I chose well for the
quiz topic and it will be helpful in the future.