4 kyu
Add _ - accessors to Hash
576 of 600ineiti
Description:
Instead of having to access values in hash by
h[:one]
or
h["one"]
write a method_missing that allows to use
h._one
both for reading and writing. It should
- first check for a key as a symbol, then for a key as a string
- return nil if neither was found
- return the value upon setting a new one
- add a new key as a symbol if it doesn't exist yet
- update whatever key is there, either symbol or string
Metaprogramming
Algorithms
Similar Kata:
Stats:
Created | Jul 25, 2013 |
Published | Jul 26, 2013 |
Warriors Trained | 1741 |
Total Skips | 770 |
Total Code Submissions | 18353 |
Total Times Completed | 600 |
Ruby Completions | 576 |
Total Stars | 41 |
% of votes with a positive feedback rating | 65% of 72 |
Total "Very Satisfied" Votes | 37 |
Total "Somewhat Satisfied" Votes | 20 |
Total "Not Satisfied" Votes | 15 |