Is There any Drawback to Using #break in a Script? | Community
Skip to main content
New Participant
May 26, 2023
Solved

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

  • May 26, 2023
  • 1 reply
  • 1073 views

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.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Darshil_Shah1

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.

 

1 reply

Darshil_Shah1
Darshil_Shah1Accepted solution
Community Manager
May 26, 2023

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.