Skip to content

Commit 757d545

Browse files
committed
Use "discard" variable
1 parent 0f25099 commit 757d545

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/System.Management.Automation/engine/Utils.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -897,16 +897,15 @@ internal static bool IsAdministrator()
897897

898898
internal static bool ItemExists(string path)
899899
{
900-
bool result = false;
901900
try
902901
{
903-
result = ItemExists(path, out bool unused);
902+
return ItemExists(path, out bool _);
904903
}
905904
catch
906905
{
907906
}
908907

909-
return result;
908+
return false;
910909
}
911910

912911
internal static bool ItemExists(string path, out bool isDirectory)

src/System.Management.Automation/namespaces/FileSystemProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2893,7 +2893,7 @@ private void RemoveDirectoryInfoItem(DirectoryInfo directory, bool recurse, bool
28932893

28942894
try
28952895
{
2896-
if (!Utils.ItemExists(directory.FullName, out bool unused))
2896+
if (!Utils.ItemExists(directory.FullName, out bool _))
28972897
{
28982898
// Directory does not exist
28992899
return;
@@ -3219,7 +3219,7 @@ private bool ItemExists(string path, out ErrorRecord error)
32193219

32203220
try
32213221
{
3222-
result = Utils.ItemExists(path, out bool unused);
3222+
result = Utils.ItemExists(path, out bool _);
32233223

32243224
FileSystemItemProviderDynamicParameters itemExistsDynamicParameters =
32253225
DynamicParameters as FileSystemItemProviderDynamicParameters;

0 commit comments

Comments
 (0)