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.
the setup of this kata in PHP has really big issues. not only are most solutions wrong, including the author's, because they use the value
0.0
to detect invalid inputs, which means they fail the simple test caseassertSame(0.0, parseFloat("0.0"))
, but, contrary to all other languages, the random tests expect123.0
for something like"123abc"
, just because(float)
/floatval()
in PHP behaves differently than most other languages (e.g. for the same input JavaScript returnsNaN
, Python raises aValueError
, etc.)the description does not indicate the expected behavior at all, which means all languages likely fallback to the behavior of their builtin.
I made a fork there adding the
"0.0"
fixed test and replacing the reference solution with something saner, but i'm not going to self-approve, as this will invalidate all solutions.I checked the history of versions, those invalid solutions managed to pass because tests used the loose equality
assertEquals()
when the translation was published. it has since been changed to the more robustassertSame()
how did you determine that ? I tried a dozen solutions from the Solutions page and most worked. a few old solutions did not work because they perform no error checking at all and return
0.0
instead ofnull
for invalid inputs like"abcd"
I am not saying that the setup of this task is great, but I just completed this task in PHP.
duplicate of this issue
I understand your point, but it does not seem to be official PHP terminology. Browsing the official documentation for anonymous functions, one can read sentences such as:
The whole document uses the terms "anonymous function" and "closure" interchangeably
can you write an anonymous function for which
instanceof Closure
yieldsfalse
?