Talk:S2 Cookbook: Strings

From Dreamwidth Notes
Revision as of 05:53, 2 July 2010 by Murklins (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

I think the "Repeating a string" example might be kind of confusing because it talks about "replacing" one string with another, but no actual replacement is done, and string replacement is actually covered by the next code sample. I'm thinking something more like this:

var string sentence = "I am a quick brown fox.";
var int length = $sentence->length();
var string underline = "-";
 
# Print out the sentence.
"""<p style="font-family: courier;">$sentence""";
 
# Underline the sentence using the $underline string.
"<br />" + $underline->repeat( $length ) + "</p>";

Will print out:

I am a quick brown fox.
-----------------------

--Murklins 05:53, 2 July 2010 (UTC)