Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpchen committed Dec 3, 2024
1 parent 3810cd3 commit d7651d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/document/Powershell/docs/Language/Array.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,13 @@ using namespace System.Collections.Generic

Keyword operators has special functionalities on collections.
`-match`, `-notmatch`, `-replace`, `-split` handles for all items in the left operand collection, the result is always an array.
If the item is not a string, Powershell evaluates it to string by certain strategy.

```ps1
# Returns items that matches the regex
@('John', 'Jane', 'Janet') -match 'Jane' # Jane, Janet.
(@('John', 'Jane', 'Janet') -notmatch 'Jane') -is [array] # True, only John matches and still an array.
(gci -file) -match '.*txt$' # FileInfo[], files with FullName matches to the pattern
(@('John', 'Jane', 'Janet') -notmatch 'Jane') -is [Array] # True, only John matches and still an array.
@('John', 'Jane', 'Janet') -replace 'J','K' # Kohn Kane Kanet
'1,2,3','1,2,3' -split ',' # 1 2 3 1 2 3, strings
Expand Down
1 change: 1 addition & 0 deletions docs/document/Powershell/docs/Language/Control Flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Empty string
- Numeric zeros
- Empty collections implemented `IList`.
- Single-item collection that contains falsy value, `@(0)`, `@($null)` for example.

> [!NOTE]
> You can cast falsy values to boolean.
Expand Down

0 comments on commit d7651d1

Please sign in to comment.