Basic function question

Welcome Forums General PowerShell Q&A Basic function question

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

 
Participant
2 years ago.

  • Author
    Posts
  • #63325

    Participant
    Points: 64
    Rank: Member

    Hello,

    This question applies to all programming not just Power shell. Besides reducing the number of lines in a code if you're entering the same code more than once, is there any other benefits to using functions?

    For example, does it make the program any faster? Any other advantages / Disadvantages?

    Thank you,

    Tony

  • #63327
    Ron

    Participant
    Points: 2
    Rank: Member

    A couple that immediately come to mind.

    Re-usability. A function can be like a tool you've built and tested. You copy it out of one script and put it in another.

    Readability. Sometimes you need a large block of code to perform a seemingly simple action. By creating a function with meaningful name, you can make your code easier to follow.

  • #63330

    Participant
    Points: 64
    Rank: Member

    Thank you

  • #63391

    Participant
    Points: 0
    Rank: Member

    I'd also add that if your code is created as Advanced functions it can be packaged as a module

The topic ‘Basic function question’ is closed to new replies.

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