在Ruby中u有什么特别的含义吗?为什么要使用它
我已经见过好几次在Ruby中使用在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中的\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。。正确。可能重复的可能重复的