【问题标题】:Ruby: Error: Cannot locate this method: String.Ruby:错误:找不到此方法:字符串。
【发布时间】:2013-09-22 03:59:38
【问题描述】:

知道为什么在pry 中使用show-doc 时某些文档不起作用吗?例如。参见show-docStringArraySet 相比:

show-doc Set

From: /Users/snowcrash/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/set.rb @ line 3:
Class name: Set
Number of lines: 57

--
set.rb - defines the Set class
++
Copyright (c) 2002-2008 Akinori MUSHA <knu@iDaemons.org>

Documentation by Akinori MUSHA and Gavin Sinclair.

All rights reserved.  You can redistribute and/or modify it under the same
terms as Ruby.

  $Id: set.rb 37839 2012-11-24 18:51:45Z knu $

== Overview

This library provides the Set class, which deals with a collection

show-doc String
Error: Cannot locate this method: String.
[7] pry(main)> show-doc Array
Error: Cannot locate this method: Array.

【问题讨论】:

    标签: ruby pry


    【解决方案1】:

    尝试安装 pry-doc gem:

    gem install pry-doc
    

    根据@JayKilleen

    如果您在 Rails 环境中使用 pry,您也可以尝试 安装 jazz_hands 而不是 github.com/nixme/jazz_hands 这带来 pry 和其他 gem 功能到 rails 控制台。

    【讨论】:

    • 这很方便。例如。 show-doc 字符串来自:object.c(C 方法)。
    • 我已经安装了 pry-doc 仍然有这个问题。只是想跟随 Josh Cheek 的介绍性截屏视频,但无法通过第一个“show-doc s.each_line”vimeo.com/26391171
    • 我已经通过在我的 rails 应用程序中安装 jazz_hands 而不是 github.com/nixme/jazz_hands 解决了这个问题,这将 pry 和其他 gem 功能带入了 rails 控制台
    【解决方案2】:

    String 和 Array 不是方法,它们是类。这可能就是它在那里给你那个错误的原因。

    【讨论】:

    • Set 也是一个类,但我正在获取文档。
    【解决方案3】:

    StringArray 是用 C 编写的内置类,除非您安装了它们,否则您没有它们的文档。 Set 是用 Ruby 编写的,您可能将文档作为库的一部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-16
      • 2018-11-08
      • 1970-01-01
      相关资源
      最近更新 更多