Last active
November 19, 2022 03:34
-
-
Save havenwood/cf551e86afe86da3ff86ddd93b13325a to your computer and use it in GitHub Desktop.
Array#undigits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Undigits | |
refine Array do | |
def undigits(base = 10) | |
reverse.reduce(0) do |acc, digit| | |
acc * base + digit | |
end | |
end | |
end | |
end | |
using Undigits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment