Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

String#to_range (See related posts)

// convert a string like "1-10" to a range 1..10

class String; def to_range; Range.new(*self.split("-").map{|i|i.to_i}); end; end

You need to create an account or log in to post comments to this site.


Click here to browse all 5141 code snippets

Related Posts