7 kyu
Person Class Bug
3,052 of 7,506jhoffner
Loading description...
Debugging
Object-oriented Programming
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
When I try to fork my own solution, without having altered it, it shows
No examples found.
when run.Ruby:
This is because the older test code only works in Ruby 2.5, but not in Ruby 3.0.
Fixed in this fork
It should never be assumed that the last name comes after the first name; this is locale-dependent (and even the fact that a person always has first and last names, but that's a different story).
Added a note to the description.
Python new test framework should be used (Refer this & this for more detail)
Ruby 3.0 should be enabled (Refer this & this for more detail)
Ruby 3.0 enabled in this fork
as with many others:
test.expect
Did you mean: as with all other jhoffner katas? ;-)
*nod*
Added sample and random tests, plus added a python translation :-)
Would you also consider adding a Python section to the description? Right now it only shows Ruby code.
[duplicate comment removed]
Python example added to description
Thanks for this kata!
I think the tests should be enhanced, because one of the solutions someone has provided uses @@ class variables, which passes tests, but would fail a test like this:
p1 = Person.new('Yukihiro', 'Matsumoto', 47) p2 = Person.new('Keith', 'Salisbury', 40)
Test.assert_equals(p1.age + p2.age, 87)
I'm not sure I understand how to do this. On other problems there has been test cases already created but these ones look like they're not there. Am I supposed to create these tests to test my change to the code that already existed? I think I solved it but it keeps coming back as an error but there's no error msg so I'm wondering if this is what my problem is? I have run this in irb and it works fine.
@jhoffner Given Matsumoto is turning 50 a few months from now, you might want to update this kata on April 14? Maybe even make it a featured kata on the codewars.com homepage? xD
Totally agree with mrsn.
firstName and lastName is how we code in java -> first_name and last_name would be correct in ruby.
This comment has been hidden.
You are not returning the expected value. I've updated the test case to use a better error message.
Age should probably return Numeric rather than String.
If you return @age without using string intrepolation then it will return whatever object that @age references. It doesn't matter if it is a string or an integer.