git://git.eng.unimelb.edu.au
/
ruby_koans.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
(from parent 1:
0ba8091
)
Merge pull request #30 from greyblake/master
author
Matt Darby
<matt@protectedmethod.com>
Thu, 2 Jun 2011 22:27:09 +0000
(15:27 -0700)
committer
Matt Darby
<matt@protectedmethod.com>
Thu, 2 Jun 2011 22:27:09 +0000
(15:27 -0700)
Hash default value
koans/about_hashes.rb
patch
|
blob
|
history
diff --git
a/koans/about_hashes.rb
b/koans/about_hashes.rb
index
3e4e62c
..
2324b04
100644
(file)
--- a/
koans/about_hashes.rb
+++ b/
koans/about_hashes.rb
@@
-63,4
+63,18
@@
class AboutHashes < EdgeCase::Koan
expected = { "jim" => __, "amy" => 20, "dan" => 23, "jenny" => __ }
assert_equal __, expected == new_hash
end
+
+ def test_default_value
+ hash1 = Hash.new
+ hash1[:one] = 1
+
+ assert_equal __, hash1[:one]
+ assert_equal __, hash1[:two]
+
+ hash2 = Hash.new("dos")
+ hash2[:one] = 1
+
+ assert_equal __, hash2[:one]
+ assert_equal __, hash2[:two]
+ end
end