Empty Begin and End Blocks

Welcome Forums General PowerShell Q&A Empty Begin and End Blocks

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
1 year, 8 months ago.

  • Author
    Posts
  • #79148

    Participant
    Topics: 5
    Replies: 6
    Points: 0
    Rank: Member

    If I have nothing to put into begin and end blocks because i have no one-time initialization or cleanup code to run. Can I define a process block without a begin and end block or will it process like a single end block? If it works correctly, from a styling and readability view point, whats better, defining empty blocks or removing them?

  • #79150

    Keymaster
    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    You can omit Begin and End. Process will still act as Process.

    I personally prefer to define empty ones and do so habitually.

  • #79154

    Participant
    Topics: 1
    Replies: 1323
    Points: 1,641
    Helping Hand
    Rank: Community Hero

    Without to trying to be a smart ass but why don't you just try it? Sometimes or actually really often it's appropriate to do your own sience. If it works and does the job – it's fine. 😉

  • #79166

    Participant
    Topics: 5
    Replies: 6
    Points: 0
    Rank: Member

    Thanks Don.

    Olaf, I did try it but wasnt sure if my test was valid. If you dont specify any block its my understanding that it acts as one end block. Would still work but it wouldnt be optimal as it wouldnt pass on through the pipeline until complete. So i wasnt sure if my experiment was working optimally or not

The topic ‘Empty Begin and End Blocks’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort