links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How can I show the number of all the instances of all classes in a category?
Last updated at 2:03 am UTC on 14 December 2021


Substitute the desired category for MyCategory-Subcategory, select everything and DoIt.
| totalNumberOfAllInstances |
Transcript clear.
totalNumberOfAllInstances _ (SystemOrganization listAtCategoryNamed: 'MyCategory-Subcategory')
	inject: 0
		[:sum :each | | numberOfCurrentClassInstances |
		numberOfCurrentClassInstances _ (Smalltalk classNamed: each) allInstances size.
			show: each asString , ': ';
			show: numberOfCurrentClassInstances;
		sum _ sum + numberOfCurrentClassInstances].
Transcript cr; show: 'Total: ' , totalNumberOfAllInstances asString