Ruby appeals to me because it often lets me get do what I want to get done, rather than spending a large amount of time "setting up" the solution. So, a few examples:
Sum the non-negative numbers in the array [-1, 3, -10, 0, 5, 8, 16, -3.14159]
[-1, 3, -10, 0, 5, 8, 16, -3.14159].select { |x| x > 0 }.inject { |acc, x| acc + x }
Compared to a form common to other languages:
sum = 0;
foreach (x in [-1, 3, -10, 0, 5, 8, 16, -3.14159]) {
if(x > 0) sum += x;
}
return x;
Simple exception handling
x = method_that_might_raise_exception() rescue nil
Compared to:
try {
x = method_that_might_raise_exception()
} catch (Exception) {
x = nil
}
Granted, you may want to do more with exceptions that are thrown, and Ruby allows you, but when you want to keep things simple, Ruby doesn't stand in the way.
Ruby's open classes are a neat topic, though they can be abused:
class Array
def sum_of_squares
map { |x| x * x }.inject { |acc, x| acc + x }
end
end
[1, 3, 5, 9].sum_of_squares
There's also the rich topic of meta-programming, but that might be too much for an introduction to Ruby? I hope something here was useful to you, and I'd like to second graffic's sentiment.