Let's say I have the following (working) pseudo-code:
puts results.fields.inject('') { |string, key|
lengths[key] = calculate_length(key)
string << format(key)
}
Following the ruby-style-guide I should
- Omit parentheses for 'keyword methods', i.e.
puts
, (which would create})
orend)
anyway) - Use
do...end
for multi-line blocks
However, when replacing {...}
with do...end
it raises
undefined method `' for :title:Symbol (NoMethodError)
Therefore, is it possible to refactor this code without violenting the guideline?