ruby - 将实例方法传递给 #each 的简洁方法
问题描述
我正在寻找一种更简洁的方式传递#func
给#each
.
class My
def hello
input = %w[a b c]
input.each(&method(:func))
end
private
def func(i)
puts i
end
end
My.new.hello
有没有?
解决方案
推荐阅读
- javascript - 网站的 javascript 中未处理的异常会发生什么?
- vhdl - 如何消除由于 std_ulogic 类型与整数文字不匹配而导致的 VHDL 类型不匹配错误?
- amazon-web-services - S3 跨账户同步 - 无法将源加密对象同步到目标
- excel - 如何在 vba 用户窗体中以百分比格式输入 10-50 之间的数字文本框?
- loops - 重复 N 组命令的问题 | Katalon Chrome 扩展程序
- laravel - 如何使中间件检查角色用户并重定向到不同的视图
- r - 分组并查找数据表中每组中第一个非零的索引
- python - 如何保留任何列中没有 Nan 的重复行之一?
- reactjs - 在 material-ui react 组件中使用类样式是一个好的设计吗?
- java - withSerializationInclusion 功能在最新的 Jackson-databind-2.9.8 中不可用