From 4d1398de6364607f31795e2889418590c9aa9075 Mon Sep 17 00:00:00 2001 From: Tomas E Date: Tue, 18 Sep 2018 10:49:56 -0700 Subject: [PATCH] Typos and cleanup (#62) * Fix some typos in comments and variable names * Clean up some blank lines and unnecessary comment Also increase consistency in this regard for AboutBitwiseAndShiftOperator.cs * Correct step number for final step * Fix a typo that was missed * Fix typo in a method that was missed --- Koans/AboutBitwiseAndShiftOperator.cs | 18 +++++++----------- Koans/AboutGenericContainers.cs | 12 ++++++------ Koans/AboutLinq.cs | 4 +--- Koans/AboutMethods.cs | 2 +- Koans/AboutStrings.cs | 8 ++++---- Koans/PathToEnlightenment.cs | 3 +-- 6 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Koans/AboutBitwiseAndShiftOperator.cs b/Koans/AboutBitwiseAndShiftOperator.cs index 7aa4174..df68b75 100644 --- a/Koans/AboutBitwiseAndShiftOperator.cs +++ b/Koans/AboutBitwiseAndShiftOperator.cs @@ -15,8 +15,8 @@ public void BinaryAndOperator() //3 in binary is 0011 //With & only taking the same one else take 0,so 1 & 3 it becomes 0001. //When 0001 convert to int it becomes 1 - int x = 4 & 4; + Assert.Equal(FILL_ME_IN, x); } @@ -26,9 +26,10 @@ public void BinaryOrOperator() //Example //1 in binary is 0001 //3 in binary is 0011 - //With | it will take any 1 if either one coantins 1,so 1 & 3 it becomes 0011. + //With | it will take any 1 if either one contains 1,so 1 & 3 it becomes 0011. //When 0011 convert to int it becomes 3 int x = 4 | 4; + Assert.Equal(FILL_ME_IN, x); } @@ -68,6 +69,7 @@ public void Combination1() public void Combination2() { int x = 4 | 4 & 8; + Assert.Equal(FILL_ME_IN, x); } @@ -79,7 +81,6 @@ public void Combination3() Assert.Equal(FILL_ME_IN, x); } - [Step(8)] public void BitwiseLeftShift() { @@ -108,17 +109,14 @@ public void BitwiseRightShift() [Step(10)] public void Combination4() { - int x = (5 << 2) & 8 ^ 3; Assert.Equal(FILL_ME_IN, x); } - [Step(11)] public void Combination5() { - int x = (5 >> 2) & (~8) ^ 8; Assert.Equal(FILL_ME_IN, x); @@ -127,19 +125,17 @@ public void Combination5() [Step(12)] public void Combination6() { - int x = (8 << 2) & (~5) & 8 | 10 | (5 >> 1); Assert.Equal(FILL_ME_IN, x); } - - [Step(10)] + [Step(13)] public void AdditionWithoutPlusOrMinusOperator() { //Solve this problem without using + or - - //This is complicated problem, if you don't - //know how to solve it try to Google it. + //This is a complicated problem. If you don't + //know how to solve it, try to Google it. int a = 15; int b = 4; diff --git a/Koans/AboutGenericContainers.cs b/Koans/AboutGenericContainers.cs index e25cd89..97d430f 100644 --- a/Koans/AboutGenericContainers.cs +++ b/Koans/AboutGenericContainers.cs @@ -46,7 +46,7 @@ public void ArrayListIsNotStronglyTyped() //ArrayList can hold more than one type. ArrayList list = new ArrayList(); list.Add(42); - list.Add("fourty two"); + list.Add("forty two"); Assert.Equal(FILL_ME_IN, list[0]); Assert.Equal(FILL_ME_IN, list[1]); @@ -62,13 +62,13 @@ public void Boxing() Assert.Equal(s.GetType(), os.GetType()); Assert.Equal(s, os); - //While this it is true that everything is an object and all the above passes. Not everything is quite as it seems. + //While it is true that everything is an object and all the above passes, not everything is quite as it seems. //Under the covers .Net allocates memory for all value type objects (int, double, bool,...) on the stack. This is //considerably more efficient than a heap allocation. .Net also has the ability to put a value type onto the heap. - //(for calling methods and other reasons). The process of putting stack data into the heap is called "boxing" the + //(for calling methods and other reasons). The process of putting stack data into the heap is called "boxing". The //process of taking the value type off the heap is called "unboxing". We won't go into the details (see Jeffrey //Richter's book if you want details). This subject comes up because every time you put a value type into an - //ArrayList it must be boxed. Every time you read it from the ArrayList it must be unboxed. This can be a significat + //ArrayList it must be boxed. Every time you read it from the ArrayList it must be unboxed. This can be a significant //cost. } [Step(6)] @@ -76,7 +76,7 @@ public void ABetterDynamicSizeContainer() { //ArrayList is a .Net 1.0 container. With .Net 2.0 generics were introduced and with it a new set of collections in //System.Collections.Generic The array like container is List. List (read "list of T") is a generic class. - //The "T" in the definition of List is the type argument. You cannot declare an instace of List without also + //The "T" in the definition of List is the type argument. You cannot declare an instance of List without also //supplying a type in place of T. var list = new List(); Assert.Equal(FILL_ME_IN, list.Count); @@ -85,7 +85,7 @@ public void ABetterDynamicSizeContainer() Assert.Equal(FILL_ME_IN, list.Count); //Now just like int[], you can have a type safe dynamic sized container - //list.Add("fourty two"); //<--Unlike ArrayList this is illegal. + //list.Add("forty two"); //<--Unlike ArrayList this is illegal. //List also solves the boxing/unboxing issues of ArrayList. Unfortunately, you'll have to take Microsoft's word for it //as I can't find a way to prove it without some ugly MSIL beyond the scope of these Koans. diff --git a/Koans/AboutLinq.cs b/Koans/AboutLinq.cs index 9c715e5..a75e87e 100644 --- a/Koans/AboutLinq.cs +++ b/Koans/AboutLinq.cs @@ -24,7 +24,7 @@ 3. Execute the query. [Step(1)] public void FilterArrayData() { - //This sample uses where to find all elements of an array less than 5. + //This sample uses "where" to find all elements of an array less than 5. // The Three Parts of a LINQ Query: @@ -44,7 +44,6 @@ where n < 5 [Step(2)] public void PutYourDataInOrderUsingOrderBy() { - string[] customers = { "John", "Bill", "Maria", "George", "Anna" }; var orderedCustomers = @@ -59,7 +58,6 @@ from cust in customers [Step(3)] public void GetJustTheDataYouWantUsingTake() { - int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; //Get just the 3 first numbers. diff --git a/Koans/AboutMethods.cs b/Koans/AboutMethods.cs index cf89164..783ec9e 100644 --- a/Koans/AboutMethods.cs +++ b/Koans/AboutMethods.cs @@ -55,7 +55,7 @@ public void ExtensionMethodsWithVariableParameters() Assert.Equal(FILL_ME_IN, this.MethodWithVariableArguments("Cory", "Will", "Corey")); } - //Extension methods can extend any class my referencing + //Extension methods can extend any class by referencing //the name of the class they are extending. For example, //we can "extend" the string class like so: diff --git a/Koans/AboutStrings.cs b/Koans/AboutStrings.cs index f745f7f..b09f1b7 100644 --- a/Koans/AboutStrings.cs +++ b/Koans/AboutStrings.cs @@ -77,8 +77,8 @@ public void ACrossPlatformWayToHandleLineEndings() //the hardcoded escape sequence. A much better way //(We'll handle concatenation and better ways of that in a bit) var literalString = "I" + System.Environment.NewLine + "am a" + System.Environment.NewLine + "broken line"; - var vebatimString = FILL_ME_IN; - Assert.Equal(literalString, vebatimString); + var verbatimString = FILL_ME_IN; + Assert.Equal(literalString, verbatimString); } [Step(8)] @@ -183,7 +183,7 @@ public void NumberOfDisplayedDecimalsCanBeControlled() } [Step(19)] - public void MinimumNumberOfDisplayedDecimalsCanBeControled() + public void MinimumNumberOfDisplayedDecimalsCanBeControlled() { var str = string.Format("{0:.00}", 12.3); Assert.Equal(FILL_ME_IN, str); @@ -221,7 +221,7 @@ public void ABetterWayToConcatenateLotsOfStrings() var str = strBuilder.ToString(); Assert.Equal(FILL_ME_IN, str); - //String.Format and StringBuilder will be more efficent that concatenation. Prefer them. + //String.Format and StringBuilder will be more efficient that concatenation. Prefer them. } [Step(23)] diff --git a/Koans/PathToEnlightenment.cs b/Koans/PathToEnlightenment.cs index 2bfcd9c..4de76af 100644 --- a/Koans/PathToEnlightenment.cs +++ b/Koans/PathToEnlightenment.cs @@ -24,8 +24,7 @@ public PathToEnlightenment() //TODO: disabled due to missing functionality in netcoreapp1.0 // it will be available in 1.1 see: // https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Array.cs#L1005 - //typeof(AboutDelegates), - //typeof(AboutLambdas) + //typeof(AboutDelegates) }; } }