Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Equals method supports StringComparison that you can set as InvariantCultureIgnoreCase.
This would fail the 'name' is null. You should do the other way around: "Zach.Equals(name)".
This is acceptable but I would ignore case compare the variable 'name' just in case someone passes 'zach' to the function!
Count method accepts a predicate so you could have done the Where lambda directly into the Count method!
I wanted to do that but ended up doing an if statement in the Select method... your version is better!
You don't need the 'else' statements. If your if statements have 'return' in their conditions (like this case) and there's only one statement that can be true (the person cannot have multiple ages so it doesn't pass through multiple if statements), you don't need the 'else' keyword. You can simply write 'if'.
This is absolutely clever but I think it can be hard to read. Also, I think you could have added constants so you don't end up with magic numbers that the next person won't know what they're for.
I did the exact same thing but I created the dictionary inside of Kata class as a private static readonly dictionary. I also checked if
op
value is in the dictionary before calling it.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Agreed. Since we know that we have to check the first letter of the name, then we should lower case the first letter ONLY - lower casing the WHOLE name is a waste of memory and processing. Also, string has a method called ToLowerInvariant which can be faster than regular ToLower method, since it doesn't lower case considering the culture code.
My solution was very close to this, but yours is pretty clean! Well done!
I totally agree with this approach. Although in the kata is said that
list
will always be filled, it is a good practise to use the null operator or checking if the list has something.Loading more items...