There’s only one thing I miss in Java that Ruby doesn’t have:
String[] list = {
“Foo”,
“Bar”,
“Blaz”,
}
Note the last trailing comma. This is a syntax error in Ruby but legal in Java. If you add another element later, you don’t need to remember to add a comma to the previous entry. Minor, sure, but useful, especially with interpreted languages where syntax errors are not found until runtime.

2 responses so far ↓
1 Luke // Apr 25, 2008 at 12:00 pm
I agree, but I have grudgingly come to accept putting the comma in front of subsequent items:
thing = [ foo
, bar
, baz
]
Like I say, it’s ugly, but functional. Also it sometimes helps you see things if you need to escape a line ending (the , and \ don’t fight each other).
2 Thibaut Barrère // May 22, 2008 at 9:53 am
On my Ruby 1.8.5, the following code is valid:
list = [
"Foo",
"Bar",
"Blaz",
]
Which version of Ruby are you using?
cheers
Leave a Comment