From: Trent Jones <1337indi@...> Date: 2008-12-01T20:37:15+09:00 Subject: Control Structures G'day all, I'm new to Ruby, been studying Software Engineering at university and they have been teaching in Java. As such, I'm trying to learn as few of the basics by going through and comverting smoe of the programs I made into Ruby. At the moment, I'm struggling a bit with the control structures, if-then-else is fine, switch/case is fine. I'm just a little confused about the for and while/dowhile loops. I'm trying to make a "infinite monkeys" simulation, i.e. initiate an array of 'x' length and then fill it with random numbers, then check to see if those numbers are in order, if not, repeat the process. More or less anyway. At the moment I'm using this loop to fill the array: for num in (0..Integer(a)) monkey[num]=Integer(rand*5+1) end variable 'a' is input by the user to determine how big a sequence, i.e. 5 numbers in a row. Is this the easiest way of doing things? And then I could use a similar loop to go through and check to see if each number is in order, but again, is there a simpler way to check? Thanks in advance. TJ -- Posted via http://www.ruby-forum.com/.