3 ms·
I've been using this for years. It is a fantastic way to build up hierarchies. XML, maps, JSON, UI code etc. It is very concise, fast and produces clean code wh
by eldenbishop 17y ago
I've been using this for years. It is a fantastic way to build up hierarchies. XML, maps, JSON, UI code etc. It is very concise, fast and produces clean code which also just happens to correctly indent when you apply code formatting.
School s = new School() {{
add(new Student() {{
name = "Bobby";
age = 15;
add(new Pet() {{
name = "Fluffy";
}});
}});
}};
vs.
School sc = new School();
Student st = new Student();
st.name = "Bobby";
st.age = 15;
Pet p = new Pet();
p.name = "Fluffy";
st.add(p);
sc.add(st);