kilon.alios wrote
> Is this possible ? Is this a smart way ? How would you do it ?
IIUC I would parse just enough to separate the class name from the data, and
then let each subclass parse the data. Something like:
�� �� PythonObject fromString: '< Bone [ "side bone" , IK = True , ( 1.0 , 0.1
, 0.2) ]>'.
where:
�� �� PythonObject>>#fromString: aString
�� �� �� �� | bracketContents pythonClassName data class |
�� �� �� �� bracketContents := aString allButFirst allButLast trimBoth.
�� �� �� �� pythonClassName := bracketContents copyUpTo: Character space.
�� �� �� �� data := bracketContents copyAfter: Character space.
�� �� �� �� class := self subclasses detect: [ :c | c pythonClassName = pythonClassName
].
�� �� �� �� ^ class data: data.
-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/Dealing-with-multiple-cases-of-a-string-while-keeping-code-short-and-OOP-friendly-tp4810731p4810778.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.