Permalink
Browse files

Fixed Range#last for 1.9.

  • Loading branch information...
1 parent 3e6c51b commit a5c159ba3d07f858b3667d4c9d29d37ab8068ef3 @brixen brixen committed Mar 23, 2013
Showing with 5 additions and 1 deletion.
  1. +0 −1 kernel/common/range.rb
  2. +1 −0 kernel/common/range18.rb
  3. +4 −0 kernel/common/range19.rb
View
@@ -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
@@ -40,6 +40,7 @@ def each(&block)
end
alias_method :first, :begin
+ alias_method :last, :end
protected
View
@@ -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)

0 comments on commit a5c159b

Please sign in to comment.