+ 1

Practice example guidance (Ruby)

So I thought in expressions it goes line by line. Can someone assist me with why the answer came out the way it did? The answer was 7 x=5 unless x<8 x += 3 else x += 2 End

10th Jun 2021, 7:24 PM
Jeshua Pence
Jeshua Pence - avatar
3 Réponses
+ 4
Jeshua Pence , using <unless ...> is the same as if you are using <if not ...> so in the code sample the <else> clause is executed. this will finally give 5 + 2, which is 7. please also note, that <end> has to be in lowercase
10th Jun 2021, 8:13 PM
Lothar
Lothar - avatar
+ 3
unless will execute when the statement is false. When the statement is true, then else will be executed.
12th Jun 2021, 5:42 PM
silentlearner
silentlearner - avatar
+ 1
Pls add language on which the question about , in tags..
10th Jun 2021, 7:29 PM
Jayakrishna 🇮🇳