Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix bug in logic on listing 5.20 #772

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Errata.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ Zhou Jing | 20 | 1018 | Change paragraph beginning with "The need to support TAP
Zhou Jing | 18 | 911 | Change CommandLineRequiredAttribute to CommandLineSwitchRequiredAttribute
Zhou Jing | 18 | 902-903 | Change CommandLineAliasAttribute to CommandLineSwitchAliasAttribute
Zhou Jing | 23 | 1105 | Change `Length = 10` in listing 23.20 to `Length = 12` to show entire output message
Zhou Jing | 18 | 926-927 | Change 'LastName' references to be 'FirstName' in paragraphs
Zhou Jing | 18 | 926-927 | Change 'LastName' references to be 'FirstName' in paragraphs
Jinhang He | 5 | 255 | Edit listing 5.20 to used `image[index]` for the second print statement
9 changes: 3 additions & 6 deletions src/Chapter05.Tests/Listing05.20.ReturningAReference.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ public class ProgramTests
public void Main_InputInigoMontoya_WriteFullName()
{
string expected = @"image\[*\]=Red
image\[*\]=Black";
image\[*\]=Yellow";

IntelliTect.TestTools.Console.ConsoleAssert.ExpectLike(expected,
() =>
{
Program.Main();
});
IntelliTect.TestTools.Console.ConsoleAssert.ExpectLike(expected,
() => Program.Main());
}
}
6 changes: 3 additions & 3 deletions src/Chapter05/Listing05.20.ReturningAReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public static void Main()
#region HIGHLIGHT
// Obtain a reference to the first red pixel
ref byte redPixel = ref FindFirstRedEyePixel(image);
// Update it to be Black
redPixel = (byte)ConsoleColor.Black;
// Update it to be Yellow
redPixel = (byte)ConsoleColor.Yellow;
#endregion HIGHLIGHT
Console.WriteLine(
$"image[{index}]={(ConsoleColor)image[redPixel]}");
$"image[{index}]={(ConsoleColor)image[index]}");
}
#endregion INCLUDE
}
Loading