我有两个变形,一个在另一个.
a:= Morph new.
b:= Morph new.
a addMorph: b.
a openInWorld.
Run Code Online (Sandbox Code Playgroud)
但是当我想通过做b位置改变b的位置:100 @ 100时,它永远不会显示变化,所以我在这里缺少什么?或者是否有责任跟踪b的位置?
我试图通过Dolphin Smalltalk X6附带的教程学习Smalltalk.
我的问题涉及对具有多个消息的表达式的评估.
我的理解是首先评估简单消息,然后评估二进制消息,最后评估关键字消息(括号中的代码除外).但是,我无法将这种理解应用到以下示例中的第二行(在Dolphin Smalltalk教程中找到).
playground := Playground new.
teresa := playground add: Triangle new. "Misunderstood code"
teresa class. "Evaluates to 'Triangle'"
Run Code Online (Sandbox Code Playgroud)
如果我的理解是正确的,那么第二行将被评估:
1. Simple message 'new' sent to Triangle, triangle object as response
2. Binary message ':=' with parameter 'playground' sent to 'teresa'.
3. Keyword message 'add:' with parameter 'triangle object' sent to 'teresa'.
4. teresa class. "evaluates to 'Playground'".
Run Code Online (Sandbox Code Playgroud)
我的误解是'teresa'如何引用匿名Triangle对象而不是'playground'引用的Playground对象.
我已经查阅了Smalltalk评估的第二个解释,提到:=或添加:是特殊情况没有成功,我能想到的唯一其他解释是一个根本的误解.
任何帮助拉直我的帮助?