class TrueClass
单例对象 true 的类。
它的几个方法充当运算符
-
#&
-
#|
-
#^
另一个方法
公共实例方法
true & 对象 → true 或 false 点击切换源码
如果 object 是 false 或 nil,则返回 false,否则返回 true
true & Object.new # => true true & false # => false true & nil # => false
static VALUE
true_and(VALUE obj, VALUE obj2)
{
return RBOOL(RTEST(obj2));
}
true === other → true 或 false 点击切换源码
false === other → true 或 false
nil === other → true 或 false
true ^ 对象 → !对象 点击切换源码
如果 object 是 false 或 nil,则返回 true,否则返回 false
true ^ Object.new # => false true ^ false # => true true ^ nil # => true
static VALUE
true_xor(VALUE obj, VALUE obj2)
{
return rb_obj_not(obj2);
}
to_s → 'true' 点击切换源码
返回字符串 'true'
true.to_s # => "true"
TrueClass#inspect 是 TrueClass#to_s 的别名。
VALUE
rb_true_to_s(VALUE obj)
{
return rb_cTrueClass_to_s;
}
别名也为:inspect
true | 对象 → true 点击切换源码
返回 true
true | Object.new # => true true | false # => true true | nil # => true
参数 object 会被求值。这与使用短路运算符的 true 不同,后者仅在必要时才对操作数求值
true | raise # => Raises RuntimeError. true || raise # => true
static VALUE
true_or(VALUE obj, VALUE obj2)
{
return Qtrue;
}