I'm not sure to understand why the conversion to_i is needed in this line if array[i].to_i <= pivot.to_i as it seems to me the values are already integers ?
It was a little hard for me to understand the code as I didn't know about the algorithm. Maybe using variables names that reveal the intention would help make it easier to read ? For my own usage I just changed in your code the variables names, following your explanations, to help me understand :
I appreciate you pointing out the snake_case, I've had a bit of trouble keeping those straight as I've been moving around in languages haha. I've corrected that in the code.
As for the conversion, I simply kept that line there in case anyone ran into problems. When I was testing the code in repl.it, the conversion to integer was necessary so I didn't want anyone to run into the same error as me.
And I love what you did with the renaming of the variables and creating the swapping function. I think that is really helpful and I'll definitely keep it in mind for my next article. Thanks again for your thoughtful discussion!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is great, thanks for sharing :)
Also, if I may, I have three comments/questions about your code:
if array[i].to_i <= pivot.to_i
as it seems to me the values are already integers ?Hey Matthieu! Thanks for the comments.
I appreciate you pointing out the snake_case, I've had a bit of trouble keeping those straight as I've been moving around in languages haha. I've corrected that in the code.
As for the conversion, I simply kept that line there in case anyone ran into problems. When I was testing the code in repl.it, the conversion to integer was necessary so I didn't want anyone to run into the same error as me.
And I love what you did with the renaming of the variables and creating the swapping function. I think that is really helpful and I'll definitely keep it in mind for my next article. Thanks again for your thoughtful discussion!