You should never put any information which might give away the kata solution in the comments (without checking the "mark as having spoiler content" box) as they're visible to every one.
Removing every theoretical edge case isn't relevant and is not best pracitice and can even fall into bad practice. Staying pithy and readable is best practice. Much depends on the context whether you would use this or something else. If it's going to be used generally in a large application best to use a well worn solution or spend more than the 2 minutes creating method but you need to know the context of the method.
edge case fail (as pointed out, with an example fix) and bad runtime makes me seriously question the people calling it best practise. I would not like this in production code.
For Ruby, I pass the tests with flying colors. However when I submit... I recieve the following error:
title_to_number': undefined method +' for nil:NilClass (NoMethodError) from block in ' from block in describe'
from measure' from describe'
from `
'
Any tips on getting past this?
Cool
You should never put any information which might give away the kata solution in the comments (without checking the "mark as having spoiler content" box) as they're visible to every one.
This comment is hidden because it contains spoiler information about the solution
Range
has a#sum
method, which will cover the 0 case on its own:(1..num).sum
works perfectlyRemoving every theoretical edge case isn't relevant and is not best pracitice and can even fall into bad practice. Staying pithy and readable is best practice. Much depends on the context whether you would use this or something else. If it's going to be used generally in a large application best to use a well worn solution or spend more than the 2 minutes creating method but you need to know the context of the method.
edge case fail (as pointed out, with an example fix) and bad runtime makes me seriously question the people calling it best practise. I would not like this in production code.
fix by doing
.reduce(0, :+)
I have been able to submit now thank you.
For Ruby, I pass the tests with flying colors. However when I submit... I recieve the following error:
title_to_number': undefined method
+' for nil:NilClass (NoMethodError) fromblock in ' from
block in describe'from
measure' from
describe'from `
'
Any tips on getting past this?