Guest User

Untitled

a guest
Jul 12th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. Float.class_eval do
  2. alias_method :original_round, :round
  3. def round(decs = 0)
  4. if decs == 0
  5. self.original_round
  6. elsif decs > 0
  7. decs = decs.to_i
  8. (self * 10 ** decs).original_round.to_f / 10 ** decs
  9. else
  10. raise ArgumentError, "You can't pass negative arguments"
  11. end
  12. end
  13. end
Add Comment
Please, Sign In to add comment