web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

exit method

(0) ShareShare
ReportReport
Posted on by 1,559

Hi Friends,

This is very trival question, I have a method, type of 'Void', when I want to exit the method in middle, 'return' should be the 'code'? or it's 'break'.

Since I saw someone use 'break' to exit out of method, it's really out of regularity from other languages.

But, it's X++, just want to be sure.

 

River

*This post is locked for comments

I have the same question (0)
  • Verified answer
    KyleLeBarre Profile Picture
    747 on at

    I think break only terminates loops and switch statements.  

  • Suggested answer
    Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    Return is the right keyword.

    I would recommend consulting the documentation (X++ Keywords) if you have this type of query.

  • Ganriver1 Profile Picture
    1,559 on at

    yeah, that's what I think, but, the 'break' did exit method as far as I can tell in our code.

  • Verified answer
    Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    That doesn't make it any more correct. The compiler AX 2012 is more strict in enforcing the right syntax.

  • Ganriver1 Profile Picture
    1,559 on at

    Thanks Guys.

  • Community Member Profile Picture
    on at

    Martin is correct, if the keyword "break" is not inside a loop AX will throw an error generating incremental CIL. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans