Cuis-String escape: Difference between revisions

From Cuis CookBook
Jump to navigation Jump to search
(imported material)
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
* The only special character in CuisSmalltalk strings is $'. This is quite unusual, Let's check for example <code>\n</code> means nothing to it.
* The only special character in CuisSmalltalk strings is $'. This is quite unusual, Let's check for example <code>\n</code> means nothing to it.
<syntaxhighlight lang="smalltalk">

'hello \n world' "=> 'hello \n world' "
'hello \n world' "=> 'hello \n world' "
</syntaxhighlight>


* So, if you want to insert a $' inside a string you must just type it twice
* So, if you want to insert a $' inside a string you must just type it twice
<syntaxhighlight lang="smalltalk">

'hey it<nowiki>''</nowiki>s me!' . "=> 'hey it<nowiki>''</nowiki>s me!' "
'hey it''s me!' . "=> 'hey it''s me!' "
</syntaxhighlight>
Hey, you may say, the $' appears twice, that's not what i want! True, but let's what it is really inside the string looking at their characters we see how things really are:
'hey it<nowiki>''</nowiki>s me!' asArray . "=> #($h $e $y $ $i $t $' $s $ $m $e $!) "
Hey, you may say, the $' appears twice, that's not what i want! True, but let's what it is really inside the string looking at their characters we see how things really are:<syntaxhighlight lang="smalltalk">
'hey it''s me!' asArray . "=> #($h $e $y $ $i $t $' $s $ $m $e $!) "
</syntaxhighlight>

Latest revision as of 22:26, 4 May 2025

  • The only special character in CuisSmalltalk strings is $'. This is quite unusual, Let's check for example \n means nothing to it.
'hello \n world' "=> 'hello \n world' "
  • So, if you want to insert a $' inside a string you must just type it twice
'hey it''s me!' .    "=> 'hey it''s me!' "

Hey, you may say, the $' appears twice, that's not what i want! True, but let's what it is really inside the string looking at their characters we see how things really are:

'hey it''s me!' asArray . "=> #($h $e $y $ $i $t $' $s $ $m $e $!) "