One of my favourite ways of learning something about existing code is to load it into irb and play around with it. You are able to ask every object in irb what it can do. It is as easy as you just asking for methods
or public_methods
and the object will show its abilities. But often you get spammed by Object
or irb methods that you rarely want to use.
Hi, I am Jan. This is my old Ruby blog. I still post about Ruby, but I now do it on idiosyncratic-ruby.com. You should also install Irbtools to improve your IRB.
The multi mega method list
Project Euler 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 (Ruby)
More solutions for the projecteuler.net problems. Some of them are solved using 1.9.2 features.
Become a Proc Star!
One useful (and funny) feature of Ruby is the Symbol#to_proc
method that lets you write concise code like this: %w|1 2 3 4|.map(&:to_i)
. Almost everyone who knows this feature loves it ;). However, the use cases are pretty limited, because in most cases you need to pass parameters!
New Array and Enumerable methods in Ruby 1.9.2: keep_if, chunk...
In Ruby, dealing with Arrays and similar objects is pretty fun. And we have gotten more possibilities with Ruby 1.9.2 :)