Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Ruby中u有什么特别的含义吗?为什么要使用它_Ruby - Fatal编程技术网

在Ruby中u有什么特别的含义吗?为什么要使用它

在Ruby中u有什么特别的含义吗?为什么要使用它,ruby,Ruby,我已经见过好几次在Ruby中使用。 我不知道Ruby中的\uu有什么特殊意义。但是为什么和什么时候使用它呢 results = votes.map do |vote| popu_cost.find(-> {[]}) { |_, cost| cost <= vote }.first end results=vows.map do | vote| popu|u cost.find(->{[]}){| |,cost | cost=val} 结果\uu称为未使用变量,如果您不在其他任何

我已经见过好几次在Ruby中使用

我不知道Ruby中的
\uu
有什么特殊意义。但是为什么和什么时候使用它呢

results = votes.map do |vote|
  popu_cost.find(-> {[]}) { |_, cost| cost <= vote }.first
end
results=vows.map do | vote|
popu|u cost.find(->{[]}){| |,cost | cost=val}

结果
\uu
称为未使用变量,如果您不在其他任何地方使用它们,则不会产生任何警告。任何以
开头的变量名都称为未使用变量

假设您在
test.rb
文件中有代码:

x = 12
现在运行代码:

$ ruby -w test.rb
test.rb:1: warning: assigned but unused variable - x
$
但现在也要在下面更改代码:

_x = 12
现在再次运行,您不会看到任何警告:

$ ruby -w test.rb
$

但是,如果不使用
-w
选项运行脚本,则不会看到此警告。

\u
称为未使用变量,如果不在其他任何地方使用它们,则不会产生任何警告。任何以
开头的变量名都称为未使用变量

假设您在
test.rb
文件中有代码:

x = 12
现在运行代码:

$ ruby -w test.rb
test.rb:1: warning: assigned but unused variable - x
$
但现在也要在下面更改代码:

_x = 12
现在再次运行,您不会看到任何警告:

$ ruby -w test.rb
$

但是,如果不使用
-w
选项运行脚本,则不会看到此警告。

仅供参考。在
IRB
中,最后一个表达式位于
.
@Monk\u code Humm。。没错,只是为了小费。在
IRB
中,最后一个表达式位于
.
@Monk\u code Humm。。正确。可能重复的可能重复的