Skip to content

Instantly share code, notes, and snippets.

@pazustep
Created June 17, 2011 20:44
Show Gist options
  • Save pazustep/1032299 to your computer and use it in GitHub Desktop.
Save pazustep/1032299 to your computer and use it in GitHub Desktop.
each_with_index.map
class EachWithIndexTest < Test::Unit::TestCase
def setup
@array = ["one", "two", "three"]
end
def test_each_with_index_enumerator
enum = @array.each_with_index
assert_equal ["one", 0], enum.next
end
def test_each_with_index_and_map
@array.each_with_index.map do |item, index|
assert_not_nil item
assert_not_nil index
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment