/
Put "def" Outside of Loops
Put "def" Outside of Loops
Since the calculation counts the objects count whenever a new instance is created, you may reach the limit and get an error about too many instances. To avoid this problem, put "def" outside the loops or closures.
So instead of doing:
Too many instances
for (record in records) {
def cost = ....
}
Use this approach:
Safer approach
def cost
for (record in records) {
cost = ....
}
, multiple selections available,
Related content
List.find() Closure vs. Map.get()
List.find() Closure vs. Map.get()
More like this
Coding Style
Coding Style
Read with this
How I can resolve 'too many new instances created: 503" error?
How I can resolve 'too many new instances created: 503" error?
More like this
Source Code Auto Formatting
Source Code Auto Formatting
Read with this
Third Iteration – Further Performance Boost
Third Iteration – Further Performance Boost
More like this
Naming Conventions
Naming Conventions
Read with this
Found an issue in documentation? Write to us.