directory - 对象:目录错误:不理解#name
问题描述
以下列出目录中文件的简单代码来自这里:
(Directory name: '.')
allFilesMatching: '*.st'
do: [ :f | (f name) displayNl ]
但是,它不起作用并给出以下错误:
$ gst mysrc.st
Object: Directory error: did not understand #name:
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
Directory class(Object)>>doesNotUnderstand: #name: (SysExcept.st:1448)
UndefinedObject>>executeStatements (firstline.st:1)
我正在Debian Stable Linux上开发GNU Smalltalk 3.2.5版。
问题出在哪里,如何解决?
解决方案
我不知道是谁在rosettacode上写的,但是#name:
选择器不正确(类中不存在Directory
)。如果你检查Directory class
你不会在那里找到这样的选择器。相反,您会找到一个#working:
选择器。选择器有一个描述:
working: dirName
Change the current working directory to dirName.
您的代码将如下所示:
(Directory working: '.') allFilesMatching: '*.st' do: [ :f |
(f name) displayNl
]
推荐阅读
- c++ - 填充和保存线程之间的共享缓冲区
- reactjs - 是否可以确定参数是给定的集合类型之一?
- amazon-web-services - aws s3,为什么不列出存储桶中的所有对象?
- ios - 在 SwiftUI 中使用 Core Data
- c - C:点/箭头操作符在后台是如何工作的?
- javascript - 如何在 Tradingview 图表库中自动加载研究模板?
- python-2.7 - Elasticsearch DSL:过滤,然后在 python 中聚合
- microsoft-graph-api - 同步邮箱状态、增量与订阅的最佳实践
- modelica - 如何在块中使用未指定的数组维度?
- javascript - 使用参数行数据将数据表中的行数据传递给控制器中的方法