Skip to content

Commit

Permalink
remove useless 1.8 ruby code from Range#step, because Range#step with…
Browse files Browse the repository at this point in the history
…out block always returns enumerator
  • Loading branch information
nashby committed Dec 25, 2011
1 parent 54e522a commit 434c691
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions 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

Expand Down

0 comments on commit 434c691

Please sign in to comment.