Gem 有趣地寻找 Ruby 方法

chenge · January 20, 2019 · Last by chenge replied at January 24, 2019 · 6132 hits

通常我们会从文档找,但这个比较低效和无聊。

suggest gem 提供了一个新颖的方式。

require 'suggest'

# Object#what_returns? tells you which method returns the value
[1,2,3].what_returns? 1
=> [:first, :min]

怎么样,不错吧。

源码 https://github.com/jbodah/suggest_rb

gem install suggest_rb # 注意不是 gem install suggest

没有毛用。。。

Reply to pynix

毛也是有用的

脑洞不错,确实没有什么用。。。

很有趣啊

会遍历 methods 吗?然后遇到一个有副作用的方法。。。。卒

Reply to lithium4010

你可以用 sandbox 吧。数据用模拟数据吧。

You need to Sign in before reply, if you don't have an account, please Sign up first.