lala = ‘Koko’
tjucka = ‘tero’
asdf = ‘jfsd’
puts <?????????????????>
What should I have instead of <?????????????????> for the program to
puts one random string either “Koko”, “tero” or “jfsd”?
lala = ‘Koko’
tjucka = ‘tero’
asdf = ‘jfsd’
puts <?????????????????>
What should I have instead of <?????????????????> for the program to
puts one random string either “Koko”, “tero” or “jfsd”?
Joakim Olsson wrote:
What should I have instead of <?????????????????> for the program to
puts one random string either “Koko”, “tero” or “jfsd”?
If I understand you right, you just want to print one of them variables
randomly. Without any relationship between them you cant do it (unless
there were some way of collecting all method variables).
You could always use an array, perhaps.
puts [‘Koko’, ‘tero’, ‘jfsd’][rand(3)]
Regards,
Lee
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs