@@ -173,15 +173,6 @@ $subStringArgs = @{startIndex = 2}
173
173
$str.SubString(3, @$subStringArgs)
174
174
```
175
175
176
- Using the relaxed splatting operator, the ` 3 ` value will override the value in ` $subStringArgs ` :
177
-
178
- ``` PowerShell
179
- # This will not result in an error,
180
- # and the substring will be of length 3.
181
- $subStringArgs = @{startIndex = 2}
182
- $str.SubString(3, @?$subStringArgs)
183
- ```
184
-
185
176
Multiple splatted arguments are not allowed:
186
177
187
178
``` PowerShell
@@ -196,9 +187,40 @@ The splatted argument must be last.
196
187
$str.SubString(@@{length=2}, 2)
197
188
```
198
189
199
-
200
190
## Alternate Proposals and Considerations
201
191
192
+ ### Relaxed splatting in method invocations
193
+
194
+ Initially, we wanted to support relaxed splatting for invocation of .NET methods.
195
+ In this case, the ` 3 ` value would override the value in ` $subStringArgs ` :
196
+
197
+ ``` PowerShell
198
+ # This will not result in an error,
199
+ # and the substring will be of length 3.
200
+ $subStringArgs = @{startIndex = 2}
201
+ $str.SubString(3, @?$subStringArgs)
202
+ ```
203
+
204
+ However, some situations may make it ambiguous or unclear as to which overload you're invoking.
205
+
206
+ While not a good practice for API design, if the third overload below is added at a later date,
207
+ the meaning of the PowerShell will change when using relaxed splatting.
208
+
209
+ ``` csharp
210
+ class foo {
211
+ void static bar (int a , string b );
212
+ void static bar (int a , string b , int c );
213
+ // this third overload may be added at a later date
214
+ void static bar (int d , int a , string b , int c );
215
+ }
216
+ ```
217
+
218
+ ``` PowerShell
219
+ $params = @{a = 1; b = '2'; c = 3}
220
+
221
+ [foo]::bar(0, @?$params)
222
+ ```
223
+
202
224
### Slicing operators
203
225
204
226
The suggested use of '+' and '-' is perhaps surprising
0 commit comments