Class: FalseClass

Inherits:
Object show all
Defined in:
object.c,
object.c

Overview

The global value false is the only instance of class FalseClass and represents a logically false value in boolean expressions. The class provides operators allowing false to participate correctly in logical expressions.

Instance Method Summary collapse

Instance Method Details

#&(obj) ⇒ false #&(obj) ⇒ false

And—Returns false. obj is always evaluated as it is the argument to a method call—there is no short-circuit evaluation in this case.

Overloads:

  • #&(obj) ⇒ false

    Returns:

    • (false)
  • #&(obj) ⇒ false

    Returns:

    • (false)

1555
1556
1557
1558
1559
# File 'object.c', line 1555

static VALUE
false_and(VALUE obj, VALUE obj2)
{
    return Qfalse;
}

#===(other) ⇒ Boolean

Case Equality – For class Object, effectively the same as calling #==, but typically overridden by descendants to provide meaningful semantics in case statements.

Returns:

  • (Boolean)

144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'object.c', line 144

VALUE
rb_equal(VALUE obj1, VALUE obj2)
{
    VALUE result;

    if (obj1 == obj2) return Qtrue;
    result = rb_equal_opt(obj1, obj2);
    if (result == Qundef) {
  result = rb_funcall(obj1, id_eq, 1, obj2);
    }
    if (RTEST(result)) return Qtrue;
    return Qfalse;
}

#^(obj) ⇒ Boolean #^(obj) ⇒ Boolean

Exclusive Or—If obj is nil or false, returns false; otherwise, returns true.

Overloads:

  • #^(obj) ⇒ Boolean

    Returns:

    • (Boolean)
  • #^(obj) ⇒ Boolean

    Returns:

    • (Boolean)

1590
1591
1592
1593
1594
# File 'object.c', line 1590

static VALUE
false_xor(VALUE obj, VALUE obj2)
{
    return RTEST(obj2)?Qtrue:Qfalse;
}

#to_sObject Also known as: inspect

The string representation of false is “false”.


1539
1540
1541
1542
1543
# File 'object.c', line 1539

static VALUE
false_to_s(VALUE obj)
{
    return rb_cFalseClass_to_s;
}

#|(obj) ⇒ Boolean #|(obj) ⇒ Boolean

Or—Returns false if obj is nil or false; true otherwise.

Overloads:

  • #|(obj) ⇒ Boolean

    Returns:

    • (Boolean)
  • #|(obj) ⇒ Boolean

    Returns:

    • (Boolean)

1571
1572
1573
1574
1575
# File 'object.c', line 1571

static VALUE
false_or(VALUE obj, VALUE obj2)
{
    return RTEST(obj2)?Qtrue:Qfalse;
}