web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Community Member Profile Picture
    on at
    RE: exit method

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

  • Ganriver1 Profile Picture
    1,559 on at
    RE: exit method

    Thanks Guys.

  • Verified answer
    Martin Dráb Profile Picture
    236,160 Most Valuable Professional on at
    RE: exit method

    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
    RE: exit method

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

  • Suggested answer
    Martin Dráb Profile Picture
    236,160 Most Valuable Professional on at
    RE: exit method

    Return is the right keyword.

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

  • Verified answer
    KyleLeBarre Profile Picture
    747 on at
    RE: exit method

    I think break only terminates loops and switch statements.  

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Rahul Shah Profile Picture

Rahul Shah 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans