Indeed, thanks for pointing this out, Gavin. Basically, as of the time of writing of this comment, the format presented for Ruby is as specified by Gavin:
Your examples in the "input" section appear to be from the JavasScript version of this kata (given the use of var) and would lead someone to believe you are using symbols as your keys. For example: { firstName: 'Nikau', lastName: 'R.', country: 'New Zealand', continent: 'Oceania', age: 39, language: 'Ruby' }
In case you are not familiar with this style of litereal hash formatting, this is the same as: { :firstName => 'Nikau', :lastName => 'R.', :country => 'New Zealand', :continent => 'Oceania', :age => 39, :language => 'Ruby' }
However your test cases use String keys and snake case for the keys. Example: { "first_name" => "Nikau", "last_name" => 'R.', "country" => "New Zealand", "continent" => "Oceania", "age" => 39, "language" => "Ruby" }
If you were not intending on having the kata practice handling both Symbol and String keys (as well as the different cases) then you should update the input to follow the expected keys. The description says that the test cases will follow exactly the form shown.
Wow that top solution is magical
String include the Comparable moudle which give you
the ability to compare strings using the regular
relation operators (>, <, >=, <=)
https://ruby-doc.org/core-2.7.2/Comparable.html
Ruby will consider "0" < "5" (same with "1", "2", "3", and "4")
How does the || s < "5" || part work if 5 was a string and not an integer?
Can the less than (<) operator read strings?
Description updated, let me know if I forgot anything else.
Indeed, thanks for pointing this out, Gavin. Basically, as of the time of writing of this comment, the format presented for Ruby is as specified by Gavin:
{ "first_name" => "Nikau", "last_name" => 'R.', "country" => "New Zealand", "continent" => "Oceania", "age" => 39, "language" => "Ruby" }
Your examples in the "input" section appear to be from the JavasScript version of this kata (given the use of
var
) and would lead someone to believe you are using symbols as your keys. For example:{ firstName: 'Nikau', lastName: 'R.', country: 'New Zealand', continent: 'Oceania', age: 39, language: 'Ruby' }
In case you are not familiar with this style of litereal hash formatting, this is the same as:
{ :firstName => 'Nikau', :lastName => 'R.', :country => 'New Zealand', :continent => 'Oceania', :age => 39, :language => 'Ruby' }
However your test cases use
String
keys and snake case for the keys. Example:{ "first_name" => "Nikau", "last_name" => 'R.', "country" => "New Zealand", "continent" => "Oceania", "age" => 39, "language" => "Ruby" }
If you were not intending on having the kata practice handling both
Symbol
andString
keys (as well as the different cases) then you should update the input to follow the expected keys. The description says that the test cases will follow exactly the form shown.woooooooooow