Professional Documents
Culture Documents
Migrating To Ruby 1.9
Migrating To Ruby 1.9
Migrating To Ruby 1.9
Ruby 1.9
Bruce Williams
Bruce Williams
Perpetrator of much random Ruby hackery, language tourist
multiply_by_2.(4)
# => 8
Parser Changes
Splat more flexibly
Text processing
“Clever” assignment with blocks
Some Hash enumerations
Metaprogramming, code generation
Tests are Good
I was surprised at how much work my 11th hour integration of the
FasterCSV code was. It was a pure Ruby library that really didn't do
a lot of fancy tricks, but I had to track down about 20 little issues
to get it running under Ruby 1.9. Thank goodness it had terrific test
coverage to lead me to the problem areas.
warning: multiple values for a block parameter (2 for 1) conferences.select do |name, city|
p [name, city]
end
# [:euruko, "Prague"]
# [:scotland_on_rails, "Edinburgh"]
# [:railsconf_europe, "Berlin"]
Hash#select (etc)
Returns a Hash
File.read("input.txt").encoding
# => #<Encoding:UTF-8>
Extended Syntax
Look-ahead (?=), (?!), look-behind (?<), (?<!)
[1,2,3,4].reduce(:+)
# => 10
Enumerable
New Enumerable methods take, group_by, drop, min_by, max_by,
count, and others.
take drop
Added to_proc
http://www.davidflanagan.com/blog/2007_08.html (older)
InfoQ, others...
This was really just an introduction.