KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a string, say '123' , and I want to convert it to the integer 123 . I know you can simply do some_string.to_i , but that converts 'lolipops' to 0 , which is not the effect I have in mind. I want it to blow up in my face when I try to convert something invalid, with a nice and painful Exception . Otherwise, I can't distinguish between a valid 0 and something that just isn't a number at all. EDIT: I was looking for the standard way of doing it, without regex trickery.
Tags (comma-separated)
Save Edits
Cancel