Skip to content

Instantly share code, notes, and snippets.

@thomasklemm
Created October 30, 2012 14:01
Show Gist options
  • Save thomasklemm/3980329 to your computer and use it in GitHub Desktop.
Save thomasklemm/3980329 to your computer and use it in GitHub Desktop.
Operations with Ranges
class Range
def end_at(x)
Range.new(self.begin, x)
end
def start_at(x)
Range.new(x, self.end)
end
end
# Initial Range
range = 1..10
# New end
p range.end_at(100)
# => 1..100
# New start
p range.start_at(5)
# => 1..5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment