【发布时间】:2010-10-17 05:55:09
【问题描述】:
我试图弄清楚如何将键和值对从一个过滤器过滤到另一个过滤器中
例如我想取这个哈希
x = { "one" => "one", "two" => "two", "three" => "three"}
y = x.some_function
y == { "one" => "one", "two" => "two"}
感谢您的帮助
编辑:可能应该提到,在这个例子中,我希望它充当白名单过滤器。也就是说,我知道我想要什么,而不是我不想要什么。
【问题讨论】:
-
听起来像是这个的副本:stackoverflow.com/questions/7430343/…
-
这能回答你的问题吗? Ruby: Easiest Way to Filter Hash Keys?