hl

Friday, 17 March 2017

Ruby Programming Language Tutorials Lec 06

Tutorial 6

Comparison Operators

     Alright let us check how the comparison operators work as we take a variable age whose value is 12 and passing and or not true and false operators let’s check it out


                                          Input                                                           Output


Another comparison operators

     So let’s check < = > operator  it compares the values of the left hand side value to the right hand side value if the left is greater so it will give the result 1 if both are equal so it return the value 0 and if the right value is greater so it will return -1 so let’s check by an example

                             Input                                                           Output


Unless

     Unless is another comparison operator if compare age of any student by 4 if greater go to school else stay home. It is also like if else statement so let’s check it out
       Input                                Output







Case – When Statement

     When - Case statement in ruby is just like switch case statement in C .As there is case in switch case statement in when case statement there when. So let’s check it out by making a simple program

                         Input                                                                    Output                                               

* If we don’t write anything or write anything which is not in when statement then else statement will run and give result Hello.

 * And if we match any matching in the when statement then it will return the respective result.



No comments:

Post a Comment