Make several components unique to one definition - in Ruby

(Ruby coding style nitpick)

Most coding style guides (and I) would prefer:

return if inst.empty?

a. inst.empty? is one method call that does not use a literal, whilst inst.count == 0 is two method calls. The count method is called returning a reference to an integer, whose == method is called passing the literal 0 by reference into it (where a comparison is made.)

b. I am always wary of having too many end keywords in the file.
(Have gotten too many SyntaxErrors on files, with messages like “unexpected end” or “missing end”, etc.)

1 Like