deprecated-mentors icon indicating copy to clipboard operation
deprecated-mentors copied to clipboard

Update ruby/clock example solution to match style guide

Open isen0011 opened this issue 7 years ago • 6 comments

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.

isen0011 avatar Oct 02 '18 18:10 isen0011

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?

iHiD avatar Oct 04 '18 17:10 iHiD

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.

emcoding avatar Oct 05 '18 07:10 emcoding

@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 avatar Oct 08 '18 16:10 kotp

@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?

iHiD avatar Oct 09 '18 00:10 iHiD

because it's being called on the Ruby object that's in code

Specifically being called on a String object, even.

kotp avatar Oct 09 '18 01:10 kotp

@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.

isen0011 avatar Oct 09 '18 02:10 isen0011