SOLVED

Is There any Drawback to Using #break in a Script?

Go to solution
nhabischWings
Level 5

Is There any Drawback to Using #break in a Script?

Hello,
Just curious if there's any drawbacks/issues with using #break in a script? For reference here is my script use case:

 

#foreach ($item in $customerProfilesList )
#if ( ( $item.age <=15 && $item.age >=13 ) && ( $item.membershipStatus.equals("Member") ) && ($item.financialEducationSOAREXPLORERGraduate.equals("0")) )
$item.fullName##
#break
#else
Wings Member##
#break
#end
#end

Basically I am looking to pull one name value (even if multiple records exist) since it's going within the same household and also to only pull one instance of the default if needed. Just curious if this has any potential ramifications? Testing-wise it seems to work correctly.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Is There any Drawback to Using #break in a Script?

AFAIK if the break statement meets your needs, I think you should be good with using it. However, IMO you might not want to overuse breaks in your code because they introduce more exit points. We generally want to keep exit points to a minimum since multiple exit points complicate logic and make it more difficult to comprehend code.

 

View solution in original post

1 REPLY 1
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Is There any Drawback to Using #break in a Script?

AFAIK if the break statement meets your needs, I think you should be good with using it. However, IMO you might not want to overuse breaks in your code because they introduce more exit points. We generally want to keep exit points to a minimum since multiple exit points complicate logic and make it more difficult to comprehend code.