Aimred Developer Blog June 2008 Archive

Ruby 1.9 Fun

Dave Thomas (of Pragmatic Programmers fame) describes some new Ruby 1.9 syntax:

first, *, last = 1,2,3,4,5
puts first
puts last

will produce

1
5

The same syntax also works for method definitions

def test( first, *, last)
  puts first
  puts last
end
test( 1, 2, 3, 4, 5 )

will produce the same output as above.

About Aimred

Aimred is a specialist Ruby and Ruby on Rails development house and consultancy based in Cape Town, South Africa.

We provide Ruby and Ruby on Rails development, consulting and training services to businesses and organisations of all sizes. If you want to find out how we can help you, contact us at info@aimred.com.