Skip to content

Instantly share code, notes, and snippets.

@Harvnlenny
Created July 2, 2015 03:10
Show Gist options
  • Save Harvnlenny/5a0bbea2f8ef24322bc2 to your computer and use it in GitHub Desktop.
Save Harvnlenny/5a0bbea2f8ef24322bc2 to your computer and use it in GitHub Desktop.
Array Reversal
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