Ruby 请问 Enumerator#each_with_object 和 Enumerator#with_object 有区别吗?

maxchen · November 22, 2018 · Last by maxchen replied at November 22, 2018 · 1059 hits

若无区别,为什么特意定义了这两个方法呢?

没有区别,别名关系

Enumerator.instance_method(:with_object) == Enumerator.instance_method(:each_with_object)返回 true

Reply to spike76

怎么忘了还能这么验证😂 ,文档里没注明 alias 还以为不一样的呢 谢谢了哈

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