我是Ruby的新手,我试图了解是否应该使用""vs 的特定时间''.
我大部分时间都在使用单引号,因为它更容易打字,但我不确定是否应该.
例如get 'user/new'vsget "user/new"
@代表以下Ruby代码:
module TestRocket
extend Module.new { attr_accessor :out }
def _test(a, b); send((call rescue()) ? a : b); end
def +@; _show _test :_pass, :_fail end
def -@; _show _test :_fail, :_pass end
def ~@; _show _pend; end
def !@; _show _desc; end
def _show(r); (TestRocket.out || $>) << r; r end
def _pass; " OK\n"; end
def _fail; " FAIL @ #{source_location * ':'}\n"; end
def _pend; "PENDING '#{call}' @ #{source_location * ':'}\n"; end
def _desc; " FIRE '#{call}'!\n"; …Run Code Online (Sandbox Code Playgroud) 我偶然发现了这个算子:
ruby-1.9.2-p290 :028 > "abc" !=~ /abc/
=> true
Run Code Online (Sandbox Code Playgroud)
这是什么?它的行为看起来不像"不匹配".