[Newbies] pretty printing
Mark Volkmann
mark at ociweb.com
Sun Sep 28 13:51:46 UTC 2008
Here is how one of my methods was pretty printed.
escape: aString
"escapes special characters in XML text"
| result |
result := ''.
aString
do: [:char | result := result
, (char caseOf: {
[$<] -> ['<'].
[$>] -> ['>'].
[$'] -> ['''].
[$"] -> ['"'].
[$&] -> ['&']}
otherwise: [char asString])].
^ result
Yikes! To my beginner eyes, that doesn't look good. What's the deal
with the excessive indentation?
BTW, comments better ways to do what this code does are welcomed.
Could I use collect for this?
---
Mark Volkmann
More information about the Beginners
mailing list