Ruby is a dynamic, object-oriented programming language known for its simplicity and elegance. Developed by Yukihiro Matsumoto in the mid-1990s, Ruby was designed to be both enjoyable for programmers and highly productive. It combines elements from several programming languages, including Perl,...
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}"...