R
Re BR
how can I convert a string '20-30' to a instance range object 20..30
thanks
thanks
how can I convert a string '20-30' to a instance range object 20..30
Am Mittwoch 16 September 2009 00:06:21 schrieb Re BR:
first, last = '20-30'.split("-")
first.to_i .. last.to_i
#=> 20..30
HTH,
Sebastian
Or:
range = string.match(/(\d+)-(\d+)/) and ($1.to_i .. $2.to_i)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.