how to use expressons as function parameters in powershell

Posted by rmeador on Stack Overflow See other posts from Stack Overflow or by rmeador
Published on 2010-05-21T20:58:27Z Indexed on 2010/05/21 21:00 UTC
Read the original article Hit count: 247

Filed under:
|
|

This is a very simple task in every language I have ever used, but I can't seem to figure it out in PowerShell. An example of what I'm talking about in C:

abs(x + y)

The expression x + y is evaluated, and the result passed to abs as the parameter... how do I do that in PowerShell? The only way I have figured out so far is to create a temporary variable to store the result of the expression, and pass that.

PowerShell seems to have very strange grammar and parsing rules that are constantly catching me by surprise, just like this situation. Does anyone know of documentation or a tutorial that explains the basic underlying theory of the language? I can't believe these are all special cases, there must be some rhyme or reason that no tutorial I have yet read explains. And yes, I've read this question, and all of those tutorials are awful. I've pretty much been relegated to learning from existing code.

© Stack Overflow or respective owner

Related posts about powershell

Related posts about parameters