[squeak-dev] Searching for eloquence if you have a moment.
gettimothy
gettimothy at zoho.com
Thu Oct 7 17:20:58 UTC 2021
Hi Folks
I am refactoring/improving the DocToCustomHelp class.
As I create CustomHelp subclasses , I have to account for name collisions on new class names.
I figure append an integer asWords and see what sticks, so If I have a
FooHelp, I need to create a FooOneHelp.
I have this ugly bit of cruft:
createValidClassName: aString
|cn i available|
cn := aString asCamelCase.
(cn endsWith:'Help')
ifFalse:[cn := cn , 'Help'].
available := false.
i := 1.
[i < 10 and:(available not)] whileTrue: [
(Smalltalk at: cn ifAbsent:[available := true])
ifTrue:[i := i + 1]
ifFalse:[
cn := aString,(i asWords copyReplaceAll:'-' with:'') asCamelCase.
(cn endsWith:'Help')
ifFalse:[cn := cn , 'Help']]].
(i >=10)
self error:'createValidClassName barfs'.
Thanks for your time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211007/ec067f42/attachment.html>
More information about the Squeak-dev
mailing list
|