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: {
                                                                [$<] -> 
['&lt;'].
                                                                [$>] -> 
['&gt;'].
                                                                [$'] -> 
['&apos;'].
                                                                [$"] -> 
['&quot;'].
                                                                [$&] -> 
['&amp;']}
                                                                 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




_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to