1. Computing
Send to a Friend via Email

New Features in Ruby 1.9.x

With the release of Ruby 1.9.x, there are some changes and features to learn in order to migrate code. Here we will introduce you to these changes and use code examples to show you how to use Ruby 1.9.1.

Top 5 New Features in Ruby 1.9
The 5 most interesting or useful features in the new Ruby 1.9.1 release.

RubyGems and Rake are Merged with Ruby
Both RubyGems and Rake are now part of the Ruby core. Installing Ruby will give you RubyGems and Rake out of the box.

Named Regexp Groups
Ruby 1.9 introduces the concept of a named capture group. You can think of named capture groups as subroutines inside of a regular expression.

YARV - Yet Another Ruby VM
YARV takes a vastly different approach to the problem of running Ruby programs. After the program is parsed and the syntax tree created, program for a virtual machine is created.

Fibers
Fibers are lighter than threads. A fiber is a bit like a method, but instead of being run in its entirety when called, a Fiber will run until it yields a value. At this point, it will save its internal state and suspend itself and control will return to the caller.

Install 1.9.x Alongside Ruby 1.8.x
Install Ruby 1.9.1 on your Linux machine alongside your current Ruby 1.8.x distribution to upgrade it. You'll have to compile the code from source, as shown in this tutorial.

Block Variable Scope
The release of Ruby 1.9.1 brings new features to be learned. Among them are the changes in block variable scope. Learn the new syntax for block variable scope introduced in Ruby 1.9.1.

The Lambda Operator
Among the new features in release of Ruby 1.9.1 is the Lambda operator, a shortcut used to make nameless methods. Learn how to use this feature introduced in Ruby 1.9.1.

Multiple Splats in Ruby 1.9.1
Among the new features in release of Ruby 1.9.1 is the ability to use more than one splat operator in an assignment or method call. Learn how to use this feature introduced in Ruby 1.9.1.

The Question Mark Operator
Among the new features in release of Ruby 1.9.1 is what the question mark operator will return. Learn what happens now in Ruby 1.9.1.

The String Index Operator
Among the new features in release of Ruby 1.9.1 is the behavior of the string index operator. Learn what happens now in Ruby 1.9.1.

Method Call Syntax Changes
Among the new features in release of Ruby 1.9.1 is that newlines are now allowed before or after the dot (method call) operator. Learn more about these dot syntax changes in Ruby 1.9.1.

Generating Random Numbers in Ruby
While no Ruby program can generate truly random numbers, Ruby does provide access to a pseudo random number generator.

©2014 About.com. All rights reserved.