Skip to content

Commit

Permalink
Typos and cleanup (#62)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tomizechsterson authored and Bobby Johnson committed Sep 18, 2018
1 parent 0f3119f commit 4d1398d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 27 deletions.
18 changes: 7 additions & 11 deletions Koans/AboutBitwiseAndShiftOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -68,6 +69,7 @@ public void Combination1()
public void Combination2()
{
int x = 4 | 4 & 8;

Assert.Equal(FILL_ME_IN, x);
}

Expand All @@ -79,7 +81,6 @@ public void Combination3()
Assert.Equal(FILL_ME_IN, x);
}


[Step(8)]
public void BitwiseLeftShift()
{
Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand Down
12 changes: 6 additions & 6 deletions Koans/AboutGenericContainers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand All @@ -62,21 +62,21 @@ 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)]
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<T>. List<T> (read "list of T") is a generic class.
//The "T" in the definition of List<T> is the type argument. You cannot declare an instace of List<T> without also
//The "T" in the definition of List<T> is the type argument. You cannot declare an instance of List<T> without also
//supplying a type in place of T.
var list = new List<int>();
Assert.Equal(FILL_ME_IN, list.Count);
Expand All @@ -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<T> 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.
Expand Down
4 changes: 1 addition & 3 deletions Koans/AboutLinq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -44,7 +44,6 @@ where n < 5
[Step(2)]
public void PutYourDataInOrderUsingOrderBy()
{

string[] customers = { "John", "Bill", "Maria", "George", "Anna" };

var orderedCustomers =
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Koans/AboutMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
8 changes: 4 additions & 4 deletions Koans/AboutStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)]
Expand Down
3 changes: 1 addition & 2 deletions Koans/PathToEnlightenment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
}
}
Expand Down

0 comments on commit 4d1398d

Please sign in to comment.