如何从GST命令行界面查看类/消息代码? 我只知道#inspect消息,但这只显示了对象的定义或摘要,而不是代码。
谢谢: - )
答案 0 :(得分:3)
您可以使用“methodSourceString”方法,例如
st>(Object >> #printNl) methodSourceString
'printNl [
"Print a represention of the receiver on stdout, put a new line
the Transcript (stdout the GUI is not active)"
<category: ''printing''>
Transcript showCr: self printString
]'
但是,字符串将使用双引号打印,这对于非平凡的代码来说可能不方便。
使用文本编辑器通常更简单,因为几乎所有类都包含在一个文件中。您也可以从REPL查询文件名:
st> Object methodDictionary anyOne methodSourceCode file
<File /usr/share/smalltalk/kernel/Object.st>