Wiki

Changes between Version 16 and Version 17 of StandardLibraryExtensionMethods

Show
Ignore:
Timestamp:
06/22/12 03:15:25 (13 years ago)
Author:
Charles
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • StandardLibraryExtensionMethods

    v16 v17  
    248248                old this[j] == this[i] 
    249249                .count == old.count 
     250 
     251 
     252    extend Stack<of T> 
     253 
     254        def clone as Stack<of T> 
     255            ensure 
     256                result is not this 
     257                result.count == .count 
     258                result.typeOf is .typeOf 
     259 
     260 
     261    extend IDictionary<of TKey, TValue> 
     262 
     263        def clone as IDictionary<of TKey, TValue>  # CC: as same 
     264            """ 
     265            Returns a new dictionary with the contents of this dictionary. 
     266            Does not clone the contents themselves. 
     267            This is sometimes known as a "shallow copy". 
     268            """ 
     269            ensure 
     270                result is not this 
     271                result.count == .count 
     272                result.typeOf is .typeOf 
     273 
     274        def get(key as TKey, default as TValue) as TValue 
     275            """ 
     276            Returns the value for the given key, or returns the default if the key is not found. 
     277            """ 
     278            ensure not .containsKey(key) implies result == default 
    250279}}} 
    251280You can see the full source for these in  the [source:cobra/trunk/Source/Cobra.Lang source Cobra.Lang directory].