I am trying out JRuby, and I was trying to figure out how to use Java's double brace initialization. However, it is not that apparent how the syntax would be.
To keep this example simple, the below Java code would create a list containing an element:
List<String> foo = new ArrayList<String>() {{
add("bar");
}};
Is this possible in JRuby, and if so, how?
ArrayList.new {{}}
doesn't make sense and results in the error: odd number list for Hash.puts ArrayList.new({{}})
.