!~ 记录在哪里?
Where is !~ documented?
Ruby 的 !~
记录在哪里?我希望它出现在 Regexp page or the String page 上,但它不在那里。而 =~
在 Regexp 页面上出现 49 次,在 String 页面上出现 8 次。
它是 on Object
,因为它可以委托给任何 =~
实现。
您可以使用 method
查找方法的所有者:
''.method(:!~)
#=> #<Method: String(Kernel)#!~>
//.method(:!~)
#=> #<Method: Regexp(Kernel)#!~>
!~
定义在 Kernel
模块中,被 Object
:
包含
String.ancestors
#=> [String, Comparable, Object, Kernel, BasicObject]
Regexp.ancestors
#=> [Regexp, Object, Kernel, BasicObject]
并且由于 Kernel
包含在(每个)Object
中,为方便起见,其实例方法记录在 Object
中。 (或如文档所述 "clarity",但 IMO 使其不太清楚)
所以这里是:Object#!~
obj !~ other → true or false
Returns true
if two objects do not match (using the =~
method), otherwise false
.
Ruby 的 !~
记录在哪里?我希望它出现在 Regexp page or the String page 上,但它不在那里。而 =~
在 Regexp 页面上出现 49 次,在 String 页面上出现 8 次。
它是 on Object
,因为它可以委托给任何 =~
实现。
您可以使用 method
查找方法的所有者:
''.method(:!~)
#=> #<Method: String(Kernel)#!~>
//.method(:!~)
#=> #<Method: Regexp(Kernel)#!~>
!~
定义在 Kernel
模块中,被 Object
:
String.ancestors
#=> [String, Comparable, Object, Kernel, BasicObject]
Regexp.ancestors
#=> [Regexp, Object, Kernel, BasicObject]
并且由于 Kernel
包含在(每个)Object
中,为方便起见,其实例方法记录在 Object
中。 (或如文档所述 "clarity",但 IMO 使其不太清楚)
所以这里是:Object#!~
obj !~ other → true or false
Returns
true
if two objects do not match (using the=~
method), otherwisefalse
.