not the best solution and not very clever.
sum
This comment has been reported as abusive
For anyone wondering, this is definitely and absolutely NOT best practice! Its not even a clever solution.
This comment is hidden because it contains spoiler information about the solution
I think you dont even need to work of this edge case. "abc"[1...-1] # => "b" "ac"[1...-1] # => "" "a"[1...-1] # => ""
Thats the only one that may be a problem ""[1...-1] #=> nil
i think its not a good Ruby practice to use the "return" keyword in the last statement
Loading collection data...
not the best solution and not very clever.
sum
for the result of the addition makes the code more self explenatoryThis comment has been reported as abusive
This comment has been reported as abusive
For anyone wondering, this is definitely and absolutely NOT best practice! Its not even a clever solution.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I think you dont even need to work of this edge case.
"abc"[1...-1] # => "b"
"ac"[1...-1] # => ""
"a"[1...-1] # => ""
Thats the only one that may be a problem
""[1...-1] #=> nil
i think its not a good Ruby practice to use the "return" keyword in the last statement