samedi 6 avril 2019

I am new to ruby language , and trying to create a text adventure game , i want to include two strings

i want the user to type anything , but it should include two strings like "look" and "right" , if both are in included in the sentence then the program will go to next line . I am new to ruby , just getting myself familiar with the language.

i have tried && and || but it doesnt work

puts " in which direction do you want to look"  
input = gets.chomp.to_s 

if input.include? == "look" && "right"  
    puts " There is a dead end on the right"  
  elsif input.include? "look" && "left"  
     puts "there is a narrow way , going towards the woods"  
  else   

    puts "i dont understand what you are trying to say"  

 end  

Aucun commentaire:

Enregistrer un commentaire