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.
I arrived at a similar solution. Is it possible to pass a null string?
Hey, thanks for the feedback.
While you are correct consider that there was no expected behaviour specified, e.g. should we return null oder string.Empty, which is the reason for me letting the method raise an exception in the case of the parameter being null.
I completly agree with that comment.
Adding a null check will solve this at the start of the function. It isn't too clear what to do for error case. I suppose returning 'null' would be ok, but throwing a new ArgumentNullException works too.
And
null
is not""
.In nearly all cases where you're passing null instead of a string, it is an error. IMO, it should cause an exception, unless you have a well-defined behavior for that case, as otherwise you're allowing bugs to propagate.
Except you're making it much more difficult to handle those errors at the source.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Most of the other solutions will fail if cc == null as well...and frankly, that's the right thing to do, unless the problem specifies a behavior for that case.
I'd suggest that two test cases are added, one where the input argument (cc) is null and where the input argument (cc) is string.Empty;
This comment is hidden because it contains spoiler information about the solution
This solution will fail if the argument (cc) == null => Calling Length property will throw a "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
This solution will fail if the argument (cc) == null => Calling Length property will throw a "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
This solution will fail if the argument (cc) == null => Calling Length property will throw a "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
This solution will fail if the argument (cc) == null => Calling Length property will throw a "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
This solution will fail if the argument (cc) == null => Calling Length property will throw a "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
This solution will fail if the argument (cc) == null => Calling ToCharArray method will throw a "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
Loading more items...