Skip to content
This repository has been archived by the owner on Feb 4, 2019. It is now read-only.

Pash does not support optional arguments #410

Open
vladimir-aubrecht opened this issue Feb 23, 2016 · 1 comment
Open

Pash does not support optional arguments #410

vladimir-aubrecht opened this issue Feb 23, 2016 · 1 comment

Comments

@vladimir-aubrecht
Copy link

Pash does not support optional arguments right now. Would be nice if literals and variables would be supported as in Powershell.

For example:

$FallbackEnvironment = "test"

function Get-Consumers-By-Consumer-On-All-Databases(
    $Environment = $FallbackEnvironment # This line will fail
)
{
}

With error:

Parse error at (67:29): Syntax error, expected: ,, )
>     $Environment = $FallbackEnvironment
                                         ^
  +CategoryInfo: ParserError, Reason: ParseException
  +FullyQualifiedErrorId: Parse
@sburnicki
Copy link
Member

In fact it does work, but only if the line after the optional argument is delimited by either , or ).
So this works

function Test-OptArg($a, $b=1,
$c = 2)
{
  $a + $b + $c
}

So Test-OptArg 7 returns 10.

This is very likely to be a grammar issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants