Ruby Programming Tutorial - Lesson 07 - More on Conditional Statements
ruby·@bilal-haider·
0.000 HBDRuby Programming Tutorial - Lesson 07 - More on Conditional Statements
 ## Nested IF conditions We are going to learn more about conditional statements in this post. Nested if conditions means .. if conditions within if conditions .. for example ``` ## Checking for a person .. if its Bilal Haider .. we tell him, that he is lovely .. name = "Bilal Haider" balance = 1000 age = 27 if name == "Bilal Haider" puts " You are cute and lovely :) " if balance <= 500 puts "Your account balance is Low! " print balance end if age >= 25 puts "You Should have a girl Friend :) " end end if name == "Haider" puts " You are cute :) " if balance <= 500 puts "Your account balance is Low! " print balance end if age >= 25 puts "You Should have a girl Friend :) " end end ``` Note in this example ... there are two main IF conditions.. which check for a specific person, if that condition is true.. then it executes the nested IF .. and only if comparison evaluates to true.. This kind of programming is called nested ifs, when we want to check one condition.. if its true.. we check another condition.. then perform certain tasks.  ## ElSIF conditional statement Its used when you have more than 1 possibilities, depending upon the possibility a different task needs to be performed. lets take an example .. ``` if balance is greater than 2000 withdraw 1000 , if balance is greater than 5000 withdraw 4000 and if balance is less than 500 withdraw nothing ```  Now you have learned about writing Nested if conditions, and also you have learned to write ELSIF conditions.. you can write any conditional logic whatsoever .. :) You need to write some code for practice. and once you master this skill, you can write programs to do amazing things for you.
👍 bilal-haider, jdcrunchman, roundbeargames, sleempeterz, fahrel, fixmod, pheystory, mindsoul, deckyherianda, derifebrianto, adaam, edguci, bryantfitnes, randomeno, marat84, tersuppgeders, cryptoasis, rraass, gmike, lays, anjackwolfm, bioysteem, kitamahal, thegreatsteemrac, tommyknocke, ronaldmcatee, bago, burdok213, jellyzed, artsyfart, upvoterick, garoldo, brocolihunter, brakker7, foobarjohn, bompalaweid, dirkthewarrior, alandesik, aardigejongen, karnoka, bartthemad, angrycliff, begentle101, twitzer, dollymolly, karnokarlientje, bfiner, dirtymackey, biancado, truckvandefoor, caroltrien, kutbediende, brachnavich, heelpopulair, dikzakjan, paranoialad, beschonkenharry, zondagpatsdag, glasreiniger, landloper, beatricewiz, decodemeself, kingwim, biooteliz, bumbastaaf, zorozo, w817, pardalam, weirdyo, bleachperdiction, wareythepotary, dominiquerdo, pardoushol, fireballz, novablast, disturbedyank, droldos, caramacela, weirdkarma, playdeaf, dahrma, mahabrahma, wiseguyhuh, tarmaland, biskopakon, drankalanka, friedrichwig, waardaarmaar, wistoepon, maradaratar, pimpoesala, prambarbara, siliwilly, scharmebran, wildoekwind, ipuffyou, misterwister, zdashmash, waardanook, ikwindje, larmalek, dashkamaska, kirrewiet, wardakoek, newiseli, prisolet, dumpsterjedi, zooidberg, krakpan, bezolder, particlepants, sniffo35, bierkaart, ambetanterik, raidrunner, kweetni, alagesia, reach1, n3wt0n, boasjes, drakkald, whatupgg, blameonthenext, weareone1, portoriko, blimbossem, proctologic, yudithvalero, derpdragon,