module Benchmarks::Helpers::Refinements
Various ‘refinements’ aka monkey-patched standard classes
Public Instance Methods
Source
# File benchmarks/benchmarks_helpers.rb, line 24 def to_unds to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1_") end
Format Ruby Integers with underscore
Integer#to_unds returns a string adding underscores to improve readability for large Integer literals.
1000000000000000.to_unds # => "1_000_000_000_000_000" 100_00000_00_0000_00.to_unds # => "1_000_000_000_000_000"
-
Original source code
-
Underscores in Numerics @ Ruby Style Guide