Created
July 2, 2015 03:10
-
-
Save Harvnlenny/5a0bbea2f8ef24322bc2 to your computer and use it in GitHub Desktop.
Array Reversal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
describe Array do | |
before do | |
@ary = %w(a b c d e) | |
@yra = '' | |
end | |
it 'it can be reversed in place' do | |
l = @ary.length | |
begin | |
until l == 0 do | |
@yra << @ary.at(l -= 1) | |
end | |
end | |
@ary = @yra.chars.to_a | |
puts @ary.inspect | |
@ary.must_equal %w(e d c b a) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment