While rewriting a big application, I am looking at some code construction I used before. There are no functional differences between them, because I get the desired outcome, the variable must be defined as either 0 or a value. But is one “any better” for any reason? And by extension this similar construction in ObjC or other languages too.
- Typical try/error:
try
set ungroupedBoxCount to count (every page item whose item layer is couponLayer and class is not group)
on error
set ungroupedBoxCount to 0
end try
- try to set the var and then go on to attempt the potentially non-returning statement
try
set ungroupedBoxCount to 0
set ungroupedBoxCount to count (every page item whose item layer is couponLayer and class is not group)
end try
- put required value outside of try and only try the potentially non-returning statement
set ungroupedBoxCount to 0
try
set ungroupedBoxCount to count (every page item whose item layer is couponLayer and class is not group)
end try