Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed Range#last for 1.9.

  • Loading branch information...
commit a5c159ba3d07f858b3667d4c9d29d37ab8068ef3 1 parent 3e6c51b
@brixen brixen authored
View
1  kernel/common/range.rb
@@ -70,7 +70,6 @@ def inspect
end
attr_reader :end
- alias_method :last, :end
def step(step_size=1) # :yields: object
return to_enum(:step, step_size) unless block_given?
View
1  kernel/common/range18.rb
@@ -40,6 +40,7 @@ def each(&block)
end
alias_method :first, :begin
+ alias_method :last, :end
protected
View
4 kernel/common/range19.rb
@@ -51,6 +51,10 @@ def first(n=undefined)
n.equal?(undefined) ? @begin : super
end
+ def last(n=undefined)
+ n.equal?(undefined) ? @end : to_a.last(n)
+ end
+
def max(&block)
return super(&block) if block_given? || (@excl && !@end.kind_of?(Numeric))
return nil if @end < @begin || (@excl && @end == @begin)
Please sign in to comment.
Something went wrong with that request. Please try again.