Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    1.to_s(36) #=> "1"
    10.to_s(36) #=> "a"
    100.to_s(36) #=> "2s"
    123456.to_s(36) #=> "2n9c"
Ruby. Where the number is the id of the record in the database or something.


Also forgot to mention, you can do the opposite with:

    "2n9c".to_i(36) #=> 123456




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: