Is `new HashMap() {{ put("this", true) }};` == `ma...
# announcements
d
Is
new HashMap() {{ put("this", true) }};
==
mapOf("this" to true)
(note the double
{{
)?
a
yes, should be
d
Thanks for confirmation!
c
Don't do
{{ }}
in frequently executed code. Each time anonymous class is created, in the days of PermGenSpace this would kill a lot of apps, nowdays it will probably just cause a slow growing memory hog which could potentially cause OutOfMemory error down the line. I think
{{ }}
should only be allowed during app initialization (which would ensure that only finite number of anonymous classes are generated) and nowhere else.
That said I'm not 100% sure I'm right, it's been 5-6 years since I researched this moment 🙂
a
I was assuming the OP wanted to use
mapOf(...)
instead; at least, I hope so 😉
c
Yup, looks like it, but I got burned on double braces at some point in my professional life, so I can't be silent 😄
d
Right, I want mapOf instread, but in the odoo xmlrpc docs, they have that for the java example...
Thanks for the insights though!