Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4183 from nashby/blockless-step-range

remove useless 1.8 ruby code from Range#step
  • Loading branch information...
commit b0a4487b0ecc86ebc2abc0432ab301aaac6e065a 2 parents d04428d + 434c691
@josevalim josevalim authored
Showing with 5 additions and 21 deletions.
  1. +5 −21 activesupport/lib/active_support/core_ext/range/blockless_step.rb
View
26 activesupport/lib/active_support/core_ext/range/blockless_step.rb
@@ -1,27 +1,11 @@
require 'active_support/core_ext/module/aliasing'
class Range
- begin
- (1..2).step
- # Range#step doesn't return an Enumerator
- rescue LocalJumpError
- # Return an array when step is called without a block.
- def step_with_blockless(*args, &block)
- if block_given?
- step_without_blockless(*args, &block)
- else
- array = []
- step_without_blockless(*args) { |step| array << step }
- array
- end
- end
- else
- def step_with_blockless(*args, &block) #:nodoc:
- if block_given?
- step_without_blockless(*args, &block)
- else
- step_without_blockless(*args).to_a
- end
+ def step_with_blockless(*args, &block) #:nodoc:
+ if block_given?
+ step_without_blockless(*args, &block)
+ else
+ step_without_blockless(*args).to_a
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.