

if this condition is not meant then we needed something else. Remember this, if you used as an expression don't forget the else block, otherwise you wll see big red error (I means it's not so great). That's is one of the feature of Kotlin var x = 10 We have two variable typed Int, named x and y with respective value assigned.Ĭheck which value is greater and assign that value to another variable named max, and print it out.Ībove code block is same as below code block, but short and concise. We can used if or if else or if else if else if else as expression. If(name = "jenny") println("Hi I'm Jenny") else println("Who Am I?!")Ībove code block is equivalent to below code block, but short var name = "Jenny" Println("No Food!!, let's go to market place")Ĭhange isHungry, isFoodHere, isOrange, price to something your likeĮxample var isHungry = true, var isFoodHere = true, isOrange = false, price = 0.1 if you don't know the price, just say "orange are so expensive".if higher than 10 dollor, buy 10 oranges.if lower than or equal to 10 dollor, buy 20 oranges.Take a deep breath, apperiate your effort, let's keep going. Var isHungry = true to var isHungry = falseĭid you realize that you are starting to realized if and if else, also nested if else. at condition three ( // 3 ) you are hungry, there is food, but you are not coming close to this condition, coz food is here ( isFoodHere = true), so change var isFoodHere = true to var isFoodHere = falseĤ.at condition four ( // 4 ) you are hungry, food is here, both are true, so just forget we not gonna make this far.at condition two ( // 2 ) you are hungry, there is food, both condition is true, so just scream.at condition one ( // 1 ) you are hungry, and it's true, so just scream.Here is the explaination for your hunger game. If is a conditional, control flow or what so ever you read or heard, Remeber this, when you needed to make a certain decision, if comes in handy.Ĭhange the var isHungry = true to var isHungry = false

We make decisions, every single day, some are tiny likes what should I eat? some are huge, should I break up with her/him? Right? Depend on these tiny or huge decisions shape your life( here our programming life )
