Changeset 2318
- Timestamp:
- 03/14/10 08:28:09 (2 years ago)
- Location:
- cobra/trunk
- Files:
-
- 4 modified
-
Developer/IntermediateReleaseNotes.text (modified) (1 diff)
-
Source/Boxes.cobra (modified) (1 diff)
-
Source/Cobra.Lang/ExtendDictionary.cobra (modified) (2 diffs)
-
Tests/240-generics/100-use-generics-collections/110-use-dictionary.cobra (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Developer/IntermediateReleaseNotes.text
r2315 r2318 64 64 ================================================================================ 65 65 66 * Added extension methods to List<of T>. @@ expand on this 66 * Added extension methods to IList<of T>. @@ expand on this 67 68 * Added extension methods to IDictionary<of TKey, TValue>. @@ expand on this 67 69 68 70 * Moved useful Utils methods to extension methods. ticket:111 -
cobra/trunk/Source/Boxes.cobra
r2316 r2318 1557 1557 return true 1558 1558 1559 get isUninitializedForLocalVars as bool is override 1560 return false # TODO: could use a more sophisticated implementation 1561 1559 1562 get name as String is override 1560 1563 return _name -
cobra/trunk/Source/Cobra.Lang/ExtendDictionary.cobra
r2246 r2318 18 18 return newDict 19 19 20 def get(key as TKey, default as TValue) as TValue 21 """ 22 Returns the value for the given key, or returns the default if the key is not found. 23 """ 24 ensure not .containsKey(key) implies result == default 25 value as TValue 26 if .tryGetValue(key, out value), return value 27 else, return default 28 29 20 30 class TestIDictionaryExtensions 21 31 … … 32 42 assert b.count == 2 33 43 assert b['x'] == 1 and b['y'] == 2 44 45 d = {'a': 1, 'b': 2} 46 assert d.get('a', 0) == 1 47 assert d.get('c', 1) == 1 -
cobra/trunk/Tests/240-generics/100-use-generics-collections/110-use-dictionary.cobra
r1177 r2318 13 13 for value1 as String in t.values 14 14 assert value1.length 15 assert t.get('a', 'c') == 'b' 16 assert t.get('x', 'c') == 'c' 15 17 16 18 u as Dictionary<of String, int> = Dictionary<of String, int>()



