Category: Ruby

Ruby While Loop

Ruby While Loop The Ruby While loop statement syntax and example. The While loop executes ruby code while condition is true. While loop syntax while condition -- Ruby code end --or begin -- Ruby code end while condition While loop example...

Ruby For Loop

Ruby For Loop The Ruby For Loop statement syntax and example. For loop syntax for value in expression do -- Ruby code end For loop example $x = 1 for $x in [1,2,3,4,5] do puts("The value of x = #$x" )...

Ruby Case

Ruby CASE The Ruby CASE statement syntax and example. Ruby CASE syntax case expression when expression [, expression ...] [then] -- Ruby code else -- Ruby code end Ruby CASE example x = 3 case when x == 1 puts "false"...

Ruby If-Elsif-Else

Ruby IF-ELSIF-ELSE The Ruby IF-ELSIF-ELSE statement syntax and example. Ruby IF-ELSIF-ELSE syntax if condition_v1 -- Ruby code v1 elsif condition_v2 -- Ruby code v2 else -- Ruby code v3 end Ruby IF-ELSIF-ELSE example a = 1 b = 2 if a...