从 KRL 中的哈希中检测空 pick()
我在哈希中有一堆数据,我正在从中挑选。有时会有数据可供选择,有时则没有。知道拾取操作员何时发现某些内容以及何时未找到某些内容的最佳方法是什么,以便我可以在代码中对此做出反应?
I have a bunch of data in a hash and I am picking from it. Sometimes there will be data there to pick and sometimes there won't. What is the best way to know when there was something found by the pick operator and when there wasn't so I can react to that in my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
pick 运算符 将采用第二个可选参数,使其始终返回以下结果:一个数组。这意味着,如果选择了某些内容,则数组的长度将大于 0,否则将为 0。然后您可以使用它来执行您想要执行的操作。
示例代码/应用程序取自 http://kynetxappaday。 wordpress.com/2011/01/04/day-30-detecting-empty-pick/
The pick operator will take a second optional parameter that will make it so that it always returns the results in an array. This means that if something is picked, the length of the array will be greater than 0, otherwise it will be 0. You can then use that to do what you are wanting to do.
Example code/app taken from http://kynetxappaday.wordpress.com/2011/01/04/day-30-detecting-empty-pick/