Changeset 1588
- Timestamp:
- 08/19/08 06:52:09 (3 months ago)
- Files:
-
- 1 modified
-
cobra/trunk/Source/Utils.cobra (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/Utils.cobra
r1584 r1588 9 9 extend String 10 10 11 /#12 CC: parser error, this won''t fly:13 11 def capped as String 14 12 """ … … 16 14 Returns a blank string for a blank string. 17 15 """ 18 # CC: contracts on extension methods 19 # ensure 20 # result.length == .length 21 # result.length implies result[0] == result[0].toUpper 16 ensure 17 result.length == .length 18 result.length implies result[0] == result[0].toUpper 22 19 test 23 20 assert 'chuck'.capped == 'Chuck' … … 30 27 if .length == 0, return this 31 28 return this[0:1].toUpper + this[1:] 32 #/ 33 34 def capped as String 35 """ 36 Returns the string with the first character capitalized. 37 Returns a blank string for a blank string. 38 """ 39 test 40 assert 'chuck'.capped == 'Chuck' 41 assert 'Chuck'.capped == 'Chuck' 42 assert ''.capped == '' 43 assert ' foo'.capped == ' foo' 44 assert 'f'.capped == 'F' 45 assert '1aoeu'.capped == '1aoeu' 46 body 47 if .length == 0, return this 48 return this[0:1].toUpper + this[1:] 29 49 30 50 31 class Utils
