deprecated-mentors
deprecated-mentors copied to clipboard
Update ruby/clock example solution to match style guide
The ruby style guide currently suggests to use format or sprintf instead of String#%.
In addition, the self in the hash method is redundant, the style guide also recommends not including it here.
Thanks for the suggestion :) I personally disagree with the rubocop style guide on this one. I think % is a perfectly valid method and more elegant than format. What do other @exercism/ruby-contributors think?
I agree with both: that % is valid and more elegant, and that format is more expressive. So' I'd suggest to accept both and add that as a Talking Point to the Mentor Notes.
Because of the expressiveness, I tend towards using format in the example solution. Not feeling strongly about it, though.
@iHiD I prefer the String#% syntax, though it is concise and magical at first. It grows on you, I think. But it is definitely more familiar in the format or sprintf (especially) forms if you come from some other languages.
@kotp Yes. I agree with you.
@isen0011 What do you think about not changing the code, but adding a discussion point on this instead? I feel that % is more ideomatic (because it's being called on the Ruby object that's in code, rather than being called on Kernel), but that format is easier as a transition from a different language, so it would be nice to have both referenced in the document.
@F3PiX Would you be happy with that?
because it's being called on the Ruby object that's in code
Specifically being called on a String object, even.
@iHiD, that makes sense to me. I had thought that format was more widespread in usage - this discussion has been enlightening! I'll submit a new version later tonight for further discussion.