Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Finished about_arrays

  • Loading branch information...
commit 0dee4b51aaabc068878cb5aac042fd4e167d7d64 1 parent cba9913
@latish authored
Showing with 25 additions and 25 deletions.
  1. +25 −25 koans/about_arrays.rb
View
50 koans/about_arrays.rb
@@ -24,61 +24,61 @@ def test_array_literals
def test_accessing_array_elements
array = [:peanut, :butter, :and, :jelly]
- assert_equal __, array[0]
- assert_equal __, array.first
- assert_equal __, array[3]
- assert_equal __, array.last
- assert_equal __, array[-1]
- assert_equal __, array[-3]
+ assert_equal :peanut, array[0]
+ assert_equal :peanut, array.first
+ assert_equal :jelly, array[3]
+ assert_equal :jelly, array.last
+ assert_equal :jelly, array[-1]
+ assert_equal :butter, array[-3]
end
def test_slicing_arrays
array = [:peanut, :butter, :and, :jelly]
- assert_equal __, array[0,1]
- assert_equal __, array[0,2]
- assert_equal __, array[2,2]
- assert_equal __, array[2,20]
- assert_equal __, array[4,0]
- assert_equal __, array[4,100]
- assert_equal __, array[5,0]
+ assert_equal [:peanut], array[0,1]
+ assert_equal [:peanut,:butter], array[0,2]
+ assert_equal [:and,:jelly], array[2,2]
+ assert_equal [:and,:jelly], array[2,20]
+ assert_equal [], array[4,0]
+ assert_equal [], array[4,100]
+ assert_equal nil, array[5,0]
end
def test_arrays_and_ranges
- assert_equal __, (1..5).class
+ assert_equal Range, (1..5).class
assert_not_equal [1,2,3,4,5], (1..5)
- assert_equal __, (1..5).to_a
- assert_equal __, (1...5).to_a
+ assert_equal [1,2,3,4,5], (1..5).to_a
+ assert_equal [1,2,3,4], (1...5).to_a
end
def test_slicing_with_ranges
array = [:peanut, :butter, :and, :jelly]
- assert_equal __, array[0..2]
- assert_equal __, array[0...2]
- assert_equal __, array[2..-1]
+ assert_equal [:peanut,:butter,:and], array[0..2]
+ assert_equal [:peanut,:butter], array[0...2]
+ assert_equal [:and,:jelly], array[2..-1]
end
def test_pushing_and_popping_arrays
array = [1,2]
array.push(:last)
- assert_equal __, array
+ assert_equal [1,2,:last], array
popped_value = array.pop
- assert_equal __, popped_value
- assert_equal __, array
+ assert_equal :last, popped_value
+ assert_equal [1,2], array
end
def test_shifting_arrays
array = [1,2]
array.unshift(:first)
- assert_equal __, array
+ assert_equal [:first,1,2], array
shifted_value = array.shift
- assert_equal __, shifted_value
- assert_equal __, array
+ assert_equal :first, shifted_value
+ assert_equal [1,2], array
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.