Wiki

Changes between Version 1 and Version 2 of Strings

Show
Ignore:
Timestamp:
11/22/10 20:22:43 (14 years ago)
Author:
todd.a
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Strings

    v1 v2  
    55In Cobra code these are typed as '''String'''  (on .Net this equates to System.String) 
    66{{{ 
     7#!cobra 
    78var name as String 
    89def capitalize(title as String) 
     
    1112Within cobra you can catenate Strings explicitly with '+' 
    1213{{{ 
     14#!cobra 
    1315s1 = 'my' + 'string'  # after which s1 == "mystring" 
    1416}}} 
     
    1618Cobra also supports Python-style string slicing: 
    1719{{{ 
     20#!cobra 
    1821s = s[1:]  # chop off first char 
    1922s = s[:-1] # chop off last char 
     
    3942Char literals are (usually) a single quoted character prefixed with a '''c'''. 
    4043{{{ 
     44#!cobra 
    4145ch = c'x' 
    4246}}} 
     
    4650     \n, \r, \t, \0 
    4751{{{ 
     52#!cobra 
    4853nlch    = c'\n'   
    4954tabch   = c'\t' 
     
    6065expression at that point. 
    6166{{{ 
     67#!cobra 
    6268x='hops' 
    6369print 'hi [x]'  # outputs: hi hops 
     
    98104    Usual form 
    99105{{{ 
     106#!cobra 
    100107""" 
    101108Heres the doc string 
     
    104111e.g. 
    105112{{{ 
     113#!cobra 
    106114class BigOne 
    107115    """ 
     
    125133e.g. 
    126134{{{ 
     135#!cobra 
    127136t = sharp'System.Type.GetType(qualifiedName)' 
    128137}}} 
    129138== Examples == 
    130139{{{ 
     140#!cobra 
    131141s = 'A simple String' 
    132142