diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-12-03 20:12:07 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-12-03 20:26:57 -0200 |
commit | d5332de37963ab41372541fc8cf66f602663abf4 (patch) | |
tree | 7cef823444b6dbb4290b4cb9b3d68416f3abbc4a /activesupport/lib/active_support/number_helper | |
parent | 59ba94e8a2e6e88cdf4e13d34e18fc7c53265407 (diff) | |
download | rails-d5332de37963ab41372541fc8cf66f602663abf4.tar.gz rails-d5332de37963ab41372541fc8cf66f602663abf4.tar.bz2 rails-d5332de37963ab41372541fc8cf66f602663abf4.zip |
Remove earlier return in favor of conditional
Diffstat (limited to 'activesupport/lib/active_support/number_helper')
-rw-r--r-- | activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb b/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb index c736469355..273667fdae 100644 --- a/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb @@ -26,12 +26,15 @@ module ActiveSupport private def digits_and_rounded_number(precision) - return [1,0] if number.zero? - digits = digit_count(number) - multiplier = 10 ** (digits - precision) - rounded_number = calculate_rounded_number(multiplier) - digits = digit_count(rounded_number) # After rounding, the number of digits may have changed - [digits, rounded_number] + if number.zero? + [1, 0] + else + digits = digit_count(number) + multiplier = 10 ** (digits - precision) + rounded_number = calculate_rounded_number(multiplier) + digits = digit_count(rounded_number) # After rounding, the number of digits may have changed + [digits, rounded_number] + end end def calculate_rounded_number(multiplier) |