Ruby Tutorial – Learn how to use Ruby programming language. Ruby is an object-oriented programming language. The basic topics of Ruby are: variables, strings, methods, blocks, exceptions, arrays, loops and other control statements. Ruby tutorial Ruby Variables Ruby Strings Ruby Date...
Ruby Exceptions The Ruby exceptions syntax and example. Exceptions syntax begin --Ruby code rescue --Ruby code end Exceptions example begin puts 'Start block' raise 'Raise Error!' puts 'End block' rescue puts 'Exception Handling with rescue' begin puts 'Block in exception' end...
Ruby Methods The Ruby methods syntax and example. A Ruby method consists of: The def keyword Method name The body of the method Return value The end keyword Methods syntax def method_name -- Ruby code end --or def method_name(value_1, value_2) --...
Ruby Ranges The Ruby range represents an interval of values. The syntax of Ruby range allow you to include or exclude its ending value. Ranges syntax (1..10) (1...10) Ranges example r1 = (1..5).to_a r2 = (1...5).to_a r3 = (1..5).to_a.reverse puts "#{r1}"...