在Ruby编程语言中,$的名字是什么:

2024-06-24

我想了解更多$:但我不知道怎么称呼。

:015 > $:
=> ["/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/site_ruby/1.9.1", 
 "/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/site_ruby/1.9.1/x86_64-darwin11.1.0", 
 "/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/site_ruby", 
 "/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/vendor_ruby/1.9.1", 
 "/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin11.1.0", 
 "/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/vendor_ruby", 
 "/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1", 
 "/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1/x86_64-darwin11.1.0"]
  • 这个叫什么名字?
  • 如何以及何时使用?
  • 是否应该使用它,这是一个好的做法还是坏的做法?
  • 所有 Ruby 实现都支持它吗?
  • 有相关文档吗?

Ruby 有一些预定义的变量

Pre-defined variables
$!         The exception information message set by 'raise'.
$@         Array of backtrace of the last exception thrown.
$&         The string matched by the last successful match.
$`         The string to the left  of the last successful match.
$'         The string to the right of the last successful match.
$+         The highest group matched by the last successful match.
$1         The Nth group of the last successful match. May be > 1.
$~         The information about the last match in the current scope.
$=         The flag for case insensitive, nil by default.
$/         The input record separator, newline by default.
$\         The output record separator for the print and IO#write. Default is nil.
$,         The output field separator for the print and Array#join.
$;         The default separator for String#split.
$.         The current input line number of the last file that was read.
$<         The virtual concatenation file of the files given on command line (or from $stdin if no files were given).
$>         The default output for print, printf. $stdout by default.
$_         The last input line of string by gets or readline.
$0         Contains the name of the script being executed. May be assignable.
$*         Command line arguments given for the script sans args.
$$         The process number of the Ruby running this script.
$?         The status of the last executed child process.
$:         Load path for scripts and binary modules by load or require.
$"         The array contains the module names loaded by require.
$DEBUG     The status of the -d switch.
$FILENAME  Current input file from $<. Same as $<.filename.
$LOAD_PATH The alias to the $:.
$stderr    The current standard error output.
$stdin     The current standard input.
$stdout    The current standard output.
$VERBOSE   The verbose flag, which is set by the -v switch.
$-0        The alias to $/.
$-a        True if option -a is set. Read-only variable.
$-d        The alias to $DEBUG.
$-F        The alias to $;.
$-i        In in-place-edit mode, this variable holds the extension, otherwise nil.
$-I        The alias to $:.
$-l        True if option -l is set. Read-only variable.
$-p        True if option -p is set. Read-only variable.
$-v        The alias to $VERBOSE.
$-w        True if option -w is set.

http://www.zenspider.com/Languages/Ruby/QuickRef.html http://www.zenspider.com/Languages/Ruby/QuickRef.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在Ruby编程语言中,$的名字是什么: 的相关文章

  • 使用 mongodb/mongoid 排序时,有没有办法将所有 nil 值放在最后?

    除了问题中已有的内容之外 确实没什么可说的 使用 monoid People asc age 我首先得到零值 有没有办法总是返回nillast 或者告诉 mongodb 将 nil 视为非常高 与回答的完全一样sql中同样的问题在这里 ht
  • 使 diff-lcs 的输出可读

    我正在使用 diff lcs gem 输出两个 html 内容体之间的差异 这是示例内容 版本一 p Paragraph one Sentence one p p Paragraph two Another sentence p p Par
  • 运行“bundle install”失败并要求我运行“bundle install”

    事实上 当从我从 git 存储库克隆的现有 Rails 应用程序内部运行时 所有与 gem 相关的命令都会导致相同的错误消息 bundle install Could not find tzinfo 0 3 27 in any of the
  • 使用rails-Ajax 调用控制器方法?

    我正在尝试从视图中的按钮执行 application controller rb 中的 Ruby 方法 在昨天的一篇文章中 有人告诉我使用 Ajax 调用来执行此操作 因为如果没有它 只会在页面加载时运行 我对此很陌生 很难理解它 我安装了
  • ruby 无法复制 Fixnum

    我有一些这样的代码 ssh files id rsa pub id rsa ssh files each with index do item index ssh files index generate ssh path creator
  • 葡萄错误处理策略?

    我正在使用 Grape 和 Rails 创建 REST API 我已经有了基本的架构 并且正在寻找可以 清理 东西的地方 其中之一是错误处理 处理 我目前正在修复整个 API 的 root rb GRAPE API 基类 文件中的错误 我对
  • 如何在Rails中显示URL指向的图像

    我这里有一张图片http power itp ac cn jmyang funny fun4 jpg http power itp ac cn jmyang funny fun4 jpg我想在我的 Rails 站点中显示它 我该怎么做 您还
  • 尝试安装 Rails 时,执行 gem ... (Gem::RemoteFetcher::FetchError) 503 错误

    这是当我尝试使用 Ruby 2 1 1 和 RVM 执行 gem install Rails v 4 1 0 时出现的错误 错误 执行 gem 时 Gem RemoteFetcher FetchError 错误 响应服务不可用 503 ht
  • Rails 路由:向 root 添加(浅层)关注

    在我的routes rb中 我定义了一个问题 如下所示 concern namespaceable do resources comments do resources replies 现在 我可以将此问题添加到任何资源中 resource
  • 是否仍然可以在 Rails 4 中使用测试单元?

    从 Rails 3 2 升级到 Rails 4 后 我的应用程序可以运行 但我用测试单元编写的测试是一场灾难 据传 Minitest 与测试单元 兼容 然而 如果我尝试使用 现在捆绑的 Minitest 就会发现有很多差异 从断言 语句名称
  • ruby require 问题(与 $LOAD_PATH 有关)

    我正在尝试使用我刚刚安装的 gem 通过sudo gem install excelsior 像这样 需要 红宝石 要求 精益求精 这在 irb 中工作得很好 但是当我将完全相同的代码粘贴到 rb 文件中并尝试使用 ruby 运行它时 我得
  • 哈米尔评论结束

    我是哈米尔新手 这让我很困惑 我不喜欢删除可以注释掉的代码 但我不知道如何在 haml 中正确结束注释 这是一个代码片段 field f label member id br f text field member id field f l
  • 捆绑包安装不使用 rbenv 本地 Ruby 版本

    我正在尝试使用捆绑器为新的 Rails 项目安装 gem bundle install path 我已使用 rbenv 将本地 Ruby 版本设置为 2 3 1 但捆绑程序仍在使用我的系统 Ruby 2 0 0 rbenv local 2
  • rspec Rails 测试:如何强制 ActiveJob 作业内联运行某些测试?

    我希望我的后台作业能够内联运行某些标记的测试 我可以通过包装测试来做到这一点perform enqueued do但我希望能够用元数据标记它们 并且如果可能的话 它会自动发生 我尝试过以下方法 it does everything in t
  • puma 初始化程序不适用于 Rails 4.2

    我之前安装过很多次puma 从来没有出现过这个问题 我逐字遵循heroku 的指示 我创建了一个Procfile里面有这个 web bundle exec puma C config puma rb 这是配置文件 puma rb worke
  • Json(/hash) 到 ruby​​ 对象?

    在 Javascript 中 您可以将 json 作为对象访问 person name first Peter last Parker person name first 在红宝石中我必须像这样使用它 person name first 是
  • Capybara::ElementNotFound:无法找到 xpath“/html”

    我正在关注 Ruby on Rails 教程 http ruby railstutorial org chapters static pages http ruby railstutorial org chapters static pag
  • 如何向除rails/actioncable中的发件人之外的所有客户端发送消息?

    在socket io中 您可以向除发送者之外的所有客户端发送消息 例如 socket broadcast emit user connected 但在 Rails ActionCable 中 该怎么做呢 class BoardChannel
  • Rails:构建涉及多态关联和 STI 的查询

    我正在尝试查找有关照片的 10 条最新评论 以便将它们集成到我的 Rails 3 0 3 应用程序上的活动提要中 我有一个Photo模型 它继承自Upload使用单表继承的模型 class Upload lt ActiveRecord Ba
  • Ruby 相当于 Python 的多处理模块是什么?

    为了在 Ruby 或 Python 中获得真正的并发性 我需要创建新的进程 Python 使用以下命令使这变得非常简单multiprocessing模块 它抽象了所有 fork wait 的好处 让我专注于我的代码 Ruby 有类似的东西吗

随机推荐

  • 更改 PreferenceScreen 时保持操作栏显示

    我正在尝试在我的首选项屏幕中显示操作栏 为此 我在我的设置活动中添加了以下代码 public class PreferencesActivity extends ActionBarActivity Override protected vo
  • 如何将启动时窗口的位置定位到用户屏幕的右侧?

    我目前正在用 C 创建一个类似侧边栏的 WPF 应用程序 当用户启动应用程序时 我希望窗口自动将其自身定位到用户屏幕的一侧 我尝试了一些方法和谷歌搜索 但没有找到任何帮助 这是我正在尝试做的事情的一个例子 http prntscr com
  • 我的程序不再询问操作员

    include
  • 无法将带有特殊字符的文件名上传到Google Drive REST

    当我尝试使用 Web 应用程序将文件上传到 google Drive api 时 出现错误 并且该文件包含带重音的字符 例如 我使用两个请求上传文件 一个初始请求包含文件信息并将 uri 返回到文件应上传的位置 后续请求包含文件本身 第一次
  • iPad 表单禁用 [上一页 | 下一页]下一个]按钮

    所以我有一个存在于滑块中的表单向导 整个想法是根据人们的决定来限制他们 问题出在ipad上 在 iPad 上 它允许您点击 上一页 下一页 在表单上的字段之间移动 这打破了门控策略 在桌面浏览器上我抑制了TAB键通过在门控字段上按键时返回
  • jQuery 如果 Div 不存在

    我有 3 个图像 并且有一个功能 以便在鼠标悬停时它们淡入和淡出 如果滚动的图像具有 选定 类 我不想这样做 到目前为止我有这个代码 thumbs hover function if this hasClass selected this
  • 从函数返回多个值[重复]

    这个问题在这里已经有答案了 谁能告诉我如何从函数返回多个值 请举例说明 您在这里的选择是返回一个包含您喜欢的元素的结构 或者使函数使用指针处理参数 method 1 struct Bar int x int y struct Bar fun
  • 如何在列表视图中实现拖放?

    我发现大多数类似的问题都是几年前提出的 因此 我想知道是否有一种新的更简单的方法来实现列表视图的拖放功能 我正在从 sqilte db 中获取列表视图对象的数据 我没有找到一些简单的教程 如果有请分享链接 我找到了这个视频 https ww
  • 为 CMake 项目创建配置文件

    我正在尝试为我拥有的示例项目生成配置 CMake 文件 我的示例由两个 CMake 项目组成 一个在内部使用 spdlog 并在其界面中使用 eigen 的库 以及一个使用该库的应用程序 我们的想法是学习如何创建 Config cmake
  • 如何查明选择补助金是直接获得还是通过角色获得

    Oracle 中的陷阱之一是 有时如果在 SQLplus 中运行查询 则可以从表中进行选择 但从存储过程运行查询时则不能 为了从存储过程运行查询 您需要对象的直接授权 而不是通过角色获得的授权 如果我在 all tables 视图中看到一个
  • 熊猫情节不显示

    当在脚本 不是 IPython 中使用它时 什么也没有发生 即绘图窗口不会出现 import numpy as np import pandas as pd ts pd Series np random randn 1000 index p
  • rails_admin 更改belongs_to 下拉列表以显示不同字段的选项

    我在用rails admin 0 6 5 with Rails 4 1 6并有一个has many belongs toVolume 和 Issue 模型之间的关联设置分别为 class Volume lt ActiveRecord Bas
  • 如何修复 WebView Chrome 76 上的 CORS 错误?

    我已将请求从我的应用程序发送到 API 服务器 在WebView Chrome 76 0 3809 89上无法调用API 日志中显示以下错误 Access to XMLHttpRequest at https from origin fil
  • Android 中清除剪贴板数据

    我试图清除 Android 中的剪贴板数据 如下所示 但它没有清除它 ClipboardManager clipman ClipboardManager getSystemService CLIPBOARD SERVICE clipman
  • 如果 [super init] 返回 nil 为什么不抛出异常?

    这被认为是典型的 id init self super init if self lt initializations gt return self 但选择这样的实际上能做出适当响应的东西不是更好吗 id init self super i
  • 使用无服务器框架为 dynamodb 设置复合排序键

    我是 dynamodb 和 serverless 的新手 我已经阅读过复合排序键 https www alexdebrie com posts dynamodb one to many composite sort keys with hi
  • NAnt:用于执行任务的并行线程;这存在吗?

    我正在寻找执行能力
  • 使用 CountVectorizer 连接自定义特征

    我有一堆包含文章的文件 每篇文章都应该有一些功能 例如 文本长度 垃圾短信 都是整数或浮点数 在大多数情况下它们应该从 csv 加载 我想做的是 将这些功能与 CountVectorizer 结合起来 然后对这些文本进行分类 我看过一些教程
  • Java中的泛型,Merge方法

    我必须创建一个合并方法来将两个列表 基于数组的列表 合并在一起 我的方法有效 但现在我必须将方法更改为泛型 这是我没有泛型的方法 并且它有效 但我在将其转换为泛型时遇到了麻烦 public OrderedArrayList merge Or
  • 在Ruby编程语言中,$的名字是什么:

    我想了解更多 但我不知道怎么称呼 015 gt gt Users Nerian rvm rubies ruby 1 9 3 rc1 lib ruby site ruby 1 9 1 Users Nerian rvm rubies ruby