remove useless 1.8 ruby code from Range#step, because Range#step without block always returns enumerator
This commit is contained in:
parent
54e522a388
commit
434c691df6
@ -1,27 +1,11 @@
|
|||||||
require 'active_support/core_ext/module/aliasing'
|
require 'active_support/core_ext/module/aliasing'
|
||||||
|
|
||||||
class Range
|
class Range
|
||||||
begin
|
def step_with_blockless(*args, &block) #:nodoc:
|
||||||
(1..2).step
|
if block_given?
|
||||||
# Range#step doesn't return an Enumerator
|
step_without_blockless(*args, &block)
|
||||||
rescue LocalJumpError
|
else
|
||||||
# Return an array when step is called without a block.
|
step_without_blockless(*args).to_a
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user