Since you want to pass objects in as arguments, you'll have to pass them in as a separate list of using a message pattern like the following: someObject sendMessage:带参数的aSelector:argumentsList someObject sendMessage: aSelector withArguments: argumentList然后您将#sendMessage:withArguments:实现为:Then you'd implement #sendMessage:withArguments: as: sendMessage:带有参数的aSelector:argumentList sendMessage: aSelector withArguments: argumentList代表行事:[:del | 删除执行:aSelector withArguments::argumentList].delegates do:[:del | del perform: aSelector withArguments: :argumentList].,您将能够使用真实对象作为args转发任意复杂的消息:and you'd be able to forward arbitrarily complex messages using real objects as args: |参数| | arguments |参数:=数组 使用:新对象 与:1234.5 带有:(键"->值").arguments := Array with: Object new with: 1234.5 with: ('key'->'value'). someObject sendMessage:#foo:bar:baz:withArguments:arguments someObject sendMessage: #foo:bar:baz: withArguments: arguments我认为这对于大多数方言也是可移植的... I think this is portable to most dialects as well... 这篇关于Smalltalk中的消息转发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-24 17:33