4 ms·
Just another datapoint, but contrary to the other comments here I find your reduce example a lot more readable than the original. This could be because it's fai
by alinajaf 14y ago
Just another datapoint, but contrary to the other comments here I find your reduce example a lot more readable than the original. This could be because it's fairly idiomatic ruby.
- byroot 14y agoFor me this in idiomatic ruby would be: original_style = element.style.only('top', 'left', 'width', 'height') Or if you do not want to rely on ActiveSupport: original_style = Hash[%w(top left width height).map{ |p| [p, element.style[p]] }]
- alinajaf 14y agoWithout ActiveSupport I'd probably type something like this: %w(top left width height).reduce({}) { |memo, pos| memo[position] = @element.style[position] and memo }