Author: codertutor_3o6d0o

Ruby Strings

Ruby Strings The Ruby strings syntax and example. Strings syntax puts "This is a string." puts 'String syntax' Strings example puts "This is a string." puts 'String syntax' puts "abc - 123" puts "1234567" puts "Concatenate string A" + "BCDE" puts...

Ruby Variables

Ruby Variables The Ruby Variables syntax and examples. Local Variables syntax Local Variables variable_name = variable_value Global Variables $variable_name = variable_value Class Variables Instance Variables Local Variables example irb(main):001:0> x=1 => 1 irb(main):002:0> x => 1 irb(main):003:0> Variables example x=1 puts...

Ruby Return statement

Ruby Return statement The Ruby Return statement in method syntax and example. Return syntax while condition -- Ruby code end --or begin -- Ruby code end while condition Return example def test a = 1 b = 2 c = 3...

Ruby Each Loop

Ruby Each Loop The Ruby Each loop statement syntax and example. Each loop syntax expression.each do value -- Ruby code end Each loop example [1,2,3,4,5].each do |x| puts("The value of x = #{x}" ) end Output The value of x =...

Ruby Break statement

Ruby Break statement The Ruby Break statement is used to leave a block when a condition is fulfilled. Break Statement syntax break Break Statement example for x in 1..7 if x > 4 then break end puts "The value of x...