mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fix example using wrong method name
This commit is contained in:
@@ -12,9 +12,9 @@ module ActiveSupport #:nodoc:
|
||||
# Rounds the float with the specified precision.
|
||||
#
|
||||
# x = 1.337
|
||||
# x.round # => 1
|
||||
# x.round(1) # => 1.3
|
||||
# x.round(2) # => 1.34
|
||||
# x.round_with_precision # => 1
|
||||
# x.round_with_precision(1) # => 1.3
|
||||
# x.round_with_precision(2) # => 1.34
|
||||
def round_with_precision(precision = nil)
|
||||
precision.nil? ? round_without_precision : (self * (10 ** precision)).round / (10 ** precision).to_f
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user