跳转到内容

Smalltalk 编程/概述

来自维基教科书,面向开放世界的开放书籍
removeEventsTriggeredFor: anObject inState: aState
	"Remove all the events triggered by the receiver which would have
	been sent to anObject in the given state."

	| events |
	events := transitions at: aState ifAbsent: [ ^self ].
	events copy keysAndValuesDo:
		[:evtSym :msgSendSet |
		| newSet |
		newSet := msgSendSet reject: [:each | each receiver == anObject
			and: [ (anObject == self and: [ each selector == #newState: ]) not ] ].
		msgSendSet size = newSet size ifFalse:
			[newSet isEmpty
				ifTrue: [ events removeKey: evtSym]
				ifFalse: [ events at: evtSym put: newSet]]].

声明:大量缩进是需要重构代码的标志。CPS

华夏公益教科书