# Swift's closure
#   https://d...content-available-to-author-only...e.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Closures.html


DigitNames = {
    0 => "Zero", 1 => "One", 2 => "Two",   3 => "Three", 4 => "Four",
    5 => "Five", 6 => "Six", 7 => "Seven", 8 => "Eight", 9 => "Nine"
}
Numbers = [16, 58, 510]


strings = Numbers.map { |number|
    output = ''
    while number > 0
        output = DigitNames[number % 10] + output
        number /= 10
    end

    output
}


for s in strings
    puts s
end