0
What is the diffrence between if,if and if,else
2 Respostas
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.
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.