What is the diffrence between if,if and if,else | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the diffrence between if,if and if,else

17th Jan 2017, 7:36 AM
Hasec Boboy
Hasec Boboy - avatar
2 Answers
0
First things first, I have not yet attacked ruby. That being said, if statement run a check and then if the result of the check is TRUE it executes the following code. If you have two separate if statements each will be evaluated regardless of the result of the first one. if..else will conduct first code if TRUE and second code if FALSE. if..elseif.. else will evaluate the first and if TRUE conduct the first code. The second evaluation will not be evaluated unless the first evaluation is FALSE. Hope that helps and I hope I understood your question.
21st Jan 2017, 5:41 AM
Kevin Gilkey-Graham
Kevin Gilkey-Graham - avatar
0
if statement works only if the condition is true if the condition is not true we have to use else Eg- num=8 if num> 10 puts " num is greater than 10" else num<10 puts "num is less than 10 output num is less than 10 and elsif is used if we want to test multiple conditions.
21st Jan 2017, 7:48 AM
harshcr7