Updated koans from source.

This commit is contained in:
Jim Weirich
2010-09-12 21:33:11 -04:00
parent 0794235441
commit 57f0f4f178
7 changed files with 27 additions and 14 deletions

View File

@@ -78,13 +78,26 @@ class AboutIteration < EdgeCase::Koan
assert_equal __, result
# Files act like a collection of lines
upcase_lines = File.open("example_file.txt") do |file|
file.map { |line| line.strip.upcase }
File.open("example_file.txt") do |file|
upcase_lines = file.map { |line| line.strip.upcase }
assert_equal __, upcase_lines
end
assert_equal __, upcase_lines
# NOTE: You can create your own collections that work with each,
# map, select, etc.
end
# Bonus Question: In the previous koan, we saw the construct:
#
# File.open(filename) do |file|
# # code to read 'file'
# end
#
# Why did we do it that way instead of the following?
#
# file = File.open(filename)
# # code to read 'file'
#
# When you get to the "AboutSandwichCode" koan, recheck your answer.
end