Closed copiousfreetime closed 8 years ago
Do you have an idea of what you would present as a solution to your concerns? A PR would do wonders. I need to make one for "dead code" that I found in this exercise.
Yup, I'll work up a PR. Just wanted to see if there was agreement that this was a valid issue before working on it.
add Nil#reverse which is altering a core class of ruby
eew, let's not do that :)
Create a NullElement or other similar NullObject pattern that returns true for #nil?
eew! No, that seems like a terrible idea. Only instances of NilClass should return true for #nil?
Totally agree that we should fix the problem.
Thanks, @copiousfreetime!
There are two tests that cause solutions to this problem, to have, what I think, is non-idiomatic ruby.
Element.from_a
returntrue
for#nil?
#reverse
There are two solutions to this:
Nil#reverse
which is altering a core class of ruby, which I'm not really a fan of. Yes you could do this with refinements, but I'm not a fan of that solution eitherNullElement
or other similarNullObject
pattern that returnstrue
for#nil?
which I consider bad form also.The latter is the solution that the example program uses (https://github.com/exercism/xruby/blob/master/exercises/simple-linked-list/example.rb#L63-L65) and I think this is bad form in ruby because:
And that output is just wrong.
How should we fix this?