4 kyu
1337 Classes
285mcclaskc
Loading description...
Metaprogramming
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.
Python translation (author gone)
JavaScript translation (author gone)
Ruby 3.0 should be enabled, check details here and here.
And if possible update the github list.
Learned a lot about ruby metaprogramming, thx.
Fun task, thanks.
A single nitpick would be that the description could be improved: I understood the task that in addition to doing what needed to be done, each instance should have a
unique_class_method
andunique_instance_method
methods which return the real (unique) methods accordingly.Approved with the average
4 kyu
. Added few tests to assert not equal, as suggested by @danielpclark below.fun!
I suggest you use some test cases besides assert_equals. Unless you intended for 1337 as in "leet" solutions you will have people passing your tests without solving your problem. Try having atleast one
assert_not_eqauls
and oneexpect_error
.I suggest adding clarification that the class and method names as well as the return values can be whatever the person wants, so long as they are unique amongst the classes. From the example in the description, I assumed the specific names and values would be tested and so thought I had to make sure the class names were "Klass_" followed by an integer (starting at 0), the class methods needed to be named "unique_class_method", the instance methods needed to be named "unique_instance_method", and the return values needed to "c" or "i" followed by the same integer as in the class name.
I think the example needs to be updated to be one that would pass the new test cases. Specifically, the example has "unique_class_method" and "unique_instance_method" as the class and instance methods for both Klass_0 and Klass_1.
Besides that, I like this kata. It's an interesting problem to dynamically create classes and methods.
Makes sense. Thanks!