What is the most elegant way to split a value and units, so you have:
13min.some_method["value"] = 13
13min.some_method["unit"] = "min"
I think it should use unpack or split, but I can get it to work!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
How about String#scan:
Another way:
The reason String#split isn’t the best is because it gets rid of the delimiter, but your two strings are butted up against each other.