Skip to content

Commit 6b5266b

Browse files
committedJul 10, 2015
Missing-ternary-operator
1 parent 97a3a1b commit 6b5266b

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed
 

‎Basic/Missing-ternary-operator/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ of another expression. In this case the subexpression `$(if ...)` may be used.
2525
Yet another possible workaround is
2626

2727
```powershell
28-
$result = @($data1, $data2)[!$condition]
28+
$result = ($data1, $data2)[!$condition]
2929
```
3030

3131
It is not pretty perhaps but it preserves the original data type and it is an

‎Basic/Missing-ternary-operator/Test-1-ternary-workaround.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ $result.GetType().FullName
1111
$result
1212

1313
# this workaround preserves the original type
14-
$result = @($data1, $data2)[!$condition]
14+
$result = ($data1, $data2)[!$condition]
1515
$result.GetType().FullName
1616
$result

‎Basic/Missing-ternary-operator/Test-2-ternary-workaround.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ $result.GetType().FullName
1111
$result
1212

1313
# this workaround preserves the original type
14-
$result = @($data1, $data2)[!$condition]
14+
$result = ($data1, $data2)[!$condition]
1515
$result.GetType().FullName
1616
$result

‎Basic/Missing-ternary-operator/Test-3-part-of-expression.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ $data2 = 3
77
42 * $(if ($condition) {$data1} else {$data2})
88

99
# the workaround 2 is used as is
10-
42 * @($data1, $data2)[!$condition]
10+
42 * ($data1, $data2)[!$condition]

0 commit comments

Comments
 (0)