Unless not able to take decision



Unless is not making right decision. Assuming condition true in all the cases.
doesn't matter what the output is always "yes it is you"

Replace this line with your code. 

print "enter your name" + "\n"
name = gets.chomp
puts name
unless name == "Abhas" || name == "abhas"
    puts "yes its you"


Seems perfectly capable of telling the difference between a person named abhas and everyone else, look:

$ ruby abhas.rb 
enter your name

$ ruby abhas.rb 
enter your name
yes its you

Keep in mind what the English word "unless" means.


Oh yes.
My Bad. Thanks for help :slight_smile:


Oh Yes.
Thanks for help :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.