lundi 27 juillet 2015

variables and array items in ruby [on hold]

im kinda new to programing, so i apologize if my question is dumb, but i simply cannot make this work. Im currently working on a Program thats based on putting several things/items/aspects together and spit them out to the user. More specificly, it looks somewhat similar to this: I have an array, lets just call it Array1. Array1 has some items in it: [1, 2, 3, 4] Now i take a variable, Var1 for the sake of explanation. What i want to do now, is use the array1.sample method to 'randomly' select one of the items in my array and set my variable Var1 equal to whatever comes out of the array. So far so good, i managed to do that. Following up, i want to use an If...else method, depending on whatever var1 is. But, apparently, it does not seem to work that way.

Thanks for your help

Aucun commentaire:

Enregistrer un commentaire