From: muraken@... Date: 2016-05-31T15:10:16+00:00 Subject: [ruby-core:75800] [Ruby trunk Feature#12447] Integer#digits for extracting digits of place-value notation in any base Issue #12447 has been updated by Kenta Murata. Description updated ---------------------------------------- Feature #12447: Integer#digits for extracting digits of place-value notation in any base https://bugs.ruby-lang.org/issues/12447#change-58983 * Author: Kenta Murata * Status: Open * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- I sometimes want to extract digits of place-value notation of integer numbers. One typical use case is calculating checksum digit. I found some code extracting digits by the way like `int.to_s.chars.map(&:to_i)`. - https://github.com/joeljunstrom/ruby_luhn/blob/master/lib/luhn.rb#L43 - https://github.com/elitwin/check_digit/blob/master/lib/check_digit/damm.rb#L28 - https://github.com/elitwin/check_digit/blob/master/lib/check_digit/luhn.rb#L14 - https://github.com/elitwin/check_digit/blob/master/lib/check_digit/verhoeff.rb#L42 Introducing Integer#digits can reduce needless string allocation in such cases. The patch was pushed into the repository in github. https://github.com/mrkn/ruby/commit/5dce32d -- https://bugs.ruby-lang.org/ Unsubscribe: