法罗:#( $H $e $l $l $o ).'你好' Finder 中没有示例

发布于 2025-01-13 11:35:08 字数 592 浏览 1 评论 0原文

当我转到查找器并选择“示例”时,我不知道如何找到将 #( $H $e $l $l $o ). 转换为 的方法“你好”。 MethodFinder new findMethodsByExampleInput: #( $H $e $l $l $o ) andExpectedResult: 'Hello'. 也不起作用。

知道怎么做(*),但我想知道如何使用 Finder。

我猜 Finder 根本找不到它?我错过了什么吗?

(*) 例如,一种方法是:String newFrom: #( $H $e $l $l $o ).。另一种方法是: #($H $e $l $l $o) 将: '' 注入: [ :acc :el | acc, (el asString) ]. (尽管我不希望 Finder 找到第二种方式)

在此处输入图像描述

When I go to the finder and select "Examples" then I can't figure out how to find a method that turns #( $H $e $l $l $o ). into 'Hello'. Nor does MethodFinder new findMethodsByExampleInput: #( $H $e $l $l $o ) andExpectedResult: 'Hello'. work.

know how to do it(*), but I want to know how to utilize the Finder.

I guess the Finder simply can't find it? Am I missing something?

(*) For example, one way to do it i: String newFrom: #( $H $e $l $l $o ).. Another way would be: #($H $e $l $l $o) inject: '' into: [ :acc :el | acc, (el asString) ]. (though I would not expect the second way to be found by the Finder)

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

唱一曲作罢 2025-01-20 11:35:08

如果您将其视为将字符集合添加到字符串而不是将集合转换为字符串,您可以

'' . #( $H $e $l $l $o ) . 'Hello'

在 Finder 中搜索:,您将得到结果:

#( $H $e $l $l $o ) joinUsing: '' -> 'Hello'
'' , #( $H $e $l $l $o ) -> 'Hello'
'' join: #( $H $e $l $l $o ) -> 'Hello'

If you think about it like adding a collection of characters to a string rather than converting a collection to a string you can search for:

'' . #( $H $e $l $l $o ) . 'Hello'

in the Finder and you will get the results:

#( $H $e $l $l $o ) joinUsing: '' -> 'Hello'
'' , #( $H $e $l $l $o ) -> 'Hello'
'' join: #( $H $e $l $l $o ) -> 'Hello'
禾厶谷欠 2025-01-20 11:35:08

它找不到它。

但请注意,发送到 #($H $e $l $l $o) 的方法不会以 'Hello' 进行应答。存在的是一种使用参数 #($H $e $l $l $o) 发送到 String 的方法,该方法将回答 'Hello'。因此,在这种情况下使用 MethodFinder 的正确方法是

MethodFinder new
  findMethodsByExampleInput: {String. #( $H $e $l $l $o )}
  andExpectedResult: 'Hello'.

不幸的是,没有探索 #newFrom: 方法(大多数类端方法都没有)。

It can't find it.

Note however that there isn't a method that sent to #($H $e $l $l $o) would answer with 'Hello'. What there exists is a method that sent to String with argument #($H $e $l $l $o) will answer 'Hello'. So, the proper way to using MethodFinder in this case would have been

MethodFinder new
  findMethodsByExampleInput: {String. #( $H $e $l $l $o )}
  andExpectedResult: 'Hello'.

Unfortunately, the #newFrom: method is not explored (most class side methods aren't).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文