Skip to content
Steve Perry edited this page Nov 22, 2015 · 1 revision

View the source code

Run:

functions.ps1

Demonstrates defining and calling functions.

Here's the way you define a function:

function MoviePrice {
  param($age)

  if($age -lt 12) {
    10
  }
  else {
    15
  }
}

You can call a function with or without parentheses. You can use named arguments, or not:

MoviePrice 16
MoviePrice(7)
MoviePrice($age = 13)
MoviePrice $age = 60
Clone this wiki locally