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.
This comment is hidden because it contains spoiler information about the solution
I hesitate to say "Best Practices", since
Address
is officially deprecated,but I really think this is the best possible practice. You used the provided
API for exactly what it was meant for.
From the first paragraph of the Wikipedia article about
Y
(emphasis mine):Boxing won't occur here.
char.IsUpper
takes achar
and returns abool
.bool
(orSystem.Boolean
) has aEquals(bool)
override, so the compiler won't choose theObject.Equals(Object)
method.Using
==
is still better practice, though, asEquals
), though the I'm nearly positivebool.Equals(bool)
would be inlinedThis comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
The description of the kata said to count the positive odd integers -- and since the function takes a signed int, I was making sure nothing negative got through.
It's because
Object.defineProperty
is a bit more complex than just assigning values to target object.The second argument is a map of property names to property descriptors, which allow you to customize how the property is accessed.
The descriptor for
attack
in my code says that the value ofattack
is a function. Note, in contrast, thatisDead
hasget
rather thanvalue
in its descriptor, means that its value is calculated by the function provided.An equivalent way to define
attack
would to just set its value on the prototype, like soI chose to use
Object.defineProperties
because it also allowed me to create the "get-only" propertyisDead
.Thanks!
This comment is hidden because it contains spoiler information about the solution
Great, thanks!
A note on the PowerShell version:
\n
does not represent a newline in Powershell. Powershell escapes characters by prefixing them with backticks (`
), so a newline is represented as"`n"
.Note the difference in how Powershell echoes the following lines
The current Powershell translation has a number of issues with its whitespace.
E.g.,
Sample tests don't work (looks like they need to be placed in a class).
Actual tests pass arguments in reverse order (expected vs actual).
Instructions should specify how to handle when
searchPhrase
is empty string or null. (Does emptysearchPhrase
match everything or nothing?)Overall a fun kata though!
Thanks!
Loading more items...