I want to reset all the class variables in an application to nil. I've got as far as finding them, for example... packages := RPackageOrganizer default packages select:[:p| (p name includesSubstring: 'PharoLauncher') ]. stateToReset := packages flatCollect: [:p| p definedClasses select:[:c | (c classVarNames size > 0) and: [(c name includesSubstring: 'Configuration') not]] thenCollect:[:c| c-> c classVarNames] ]. stateToReset asDictionary keysAndValuesDo:[:class :variables| variables do: [:v| Transcript crShow: 'Clear ', class printString, ' -> ' , v printString]. ]. What could go in place of the Transcript line to set them to nil? cheers -ben |
Actually class variables are stored in a dictionary in a class. You can access that by saying: aClass classPool. So resetting all values of a class variable could be easily done with something like aClass classPool keys do: [ :k | aClass classPool at: k put: nil ]. Maybe that could be a nice addition. On Sat, Jul 29, 2017 at 9:51 AM, Ben Coman <[hidden email]> wrote:
|
thx guille. On Sat, Jul 29, 2017 at 9:40 PM, Guillermo Polito <[hidden email]> wrote:
|
btw, for the archives, I ended up using... packages := RPackageOrganizer default packages select:[:p| (p name includesSubstring: 'PharoLauncher') ]. packages do: [:p| p definedClasses do:[:class| class classPool keys do: [ :k | class classPool at: k put: nil ] ]]. cheers -ben On Sat, Jul 29, 2017 at 11:22 PM, Ben Coman <[hidden email]> wrote:
|
btw2, I submitted this to PharoLauncher repo.
cheers -ben On Thu, Aug 3, 2017 at 9:42 PM, Ben Coman <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |