Re: [PSH] Methods/functions and blank spaces



Hey Vasu,

This was changed by design. The reason being that in the context of a
cmdlet call there was no way to know whether the person was trying to do a
method call or pass 2 separate arguments. For example:

some-cmdlet $str.SubString (1 + 1)

Is this a call to the substring method? Or am I passing two parameters (the
first one being the value of the property SubString and the second being the
result of the expression (1 + 1)) ? By disallowing white space between the
method name and the parentheses we can now be sure about what the user is
requesting.

- Marcel


"Vasu" <Vasu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A1B4ED09-B29F-4222-BD32-BEC3FC30909B@xxxxxxxxxxxxxxxx
Looks like something is either broke or changed by design. Has anyone else
observed this?
The only difference between the working and the non-working statement is
the "blank space" after the word split and before the parenthesis.
--------------- Example begin --------------------------
PS C:\temp\monad_examples> $line="this,is,silly"
PS C:\temp\monad_examples> $line.Split (",")
Unexpected token '(' in expression or statement.
At line:1 char:14
+ $line.Split (" <<<< ,")
PS C:\temp\monad_examples> $line.Split(",")
this
is
silly
PS C:\temp\monad_examples>

----- Example End ---------------
Dear Microsoft folks:
If this is indeed broke, is there a best practice approach to writing
functions where there shouldn't be spaces after the function name and
before
the parenthesis? This is just how I've done it always :(



.