Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active November 19, 2022 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/cf551e86afe86da3ff86ddd93b13325a to your computer and use it in GitHub Desktop.
Save havenwood/cf551e86afe86da3ff86ddd93b13325a to your computer and use it in GitHub Desktop.
Array#undigits
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