Skip to content

Commit

Permalink
Processing manuscript comments in Chapter 7 (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMichaelis authored Oct 6, 2023
1 parent a9f8830 commit ff0cbe5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
8 changes: 0 additions & 8 deletions src/Chapter07/Listing07.20.TypeCheckingWithIsOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ public static void Main(params string[] args)
nameof(Employee)} object.");
}
}
#region HIGHLIGHT
else if (entity is Employee)
#endregion HIGHLIGHT
{
throw new InvalidOperationException(
$"Entity ({entity.GetType().FullName
}) is unexpectedly an {nameof(Employee)} object.");
}
else if(entity is null)
{
Console.WriteLine(
Expand Down
16 changes: 8 additions & 8 deletions src/Chapter07/Listing07.33.ListPatternMatching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ public static void Main(string[] args)
// e.g. --help, /h, -h, /?, -?
DisplayHelp();
break;
case [ ['/' or '-', char command], ..]:
// Command begins with '/', '-' and has 0 or more arguments.
if(!ExecuteCommand($"{command}", args[1..]))
case [ ['/' or '-', char option], ..]:
// Option begins with '/', '-' and has 0 or more arguments.
if(!EvaluateOption($"{option}", args[1..]))
{
DisplayHelp();
}
break;
case [ ['-', '-', ..] command, ..]:
// Command begins with "--" and has 0 or more arguments.
if(!ExecuteCommand(command[2..], args[1..]))
case [ ['-', '-', ..] option, ..]:
// Option begins with "--" and has 0 or more arguments.
if(!EvaluateOption(option[2..], args[1..]))
{
DisplayHelp();
}
Expand All @@ -45,8 +45,8 @@ public static void Main(string[] args)
}
}

private static bool ExecuteCommand(string command, string[] args) =>
(command, args) switch
private static bool EvaluateOption(string option, string[] args) =>
(option, args) switch
{
("cat" or "c", [string fileName]) =>
CatalogFile(fileName),
Expand Down

0 comments on commit ff0cbe5

Please sign in to comment.