Class: NilClass

Inherits:
Object show all
Defined in:
src/object.c

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)

201
202
203
204
205
# File 'src/object.c', line 201

static mrb_value
false_and(mrb_state *mrb, mrb_value obj)
{
  return mrb_false_value();
}

#^(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)

220
221
222
223
224
225
226
227
# File 'src/object.c', line 220

static mrb_value
false_xor(mrb_state *mrb, mrb_value obj)
{
  mrb_bool obj2;

  mrb_get_args(mrb, "b", &obj2);
  return mrb_bool_value(obj2);
}

#inspectObject

15.2.4.3.5


89
90
91
92
93
# File 'src/object.c', line 89

static mrb_value
nil_inspect(mrb_state *mrb, mrb_value obj)
{
  return mrb_str_new_lit(mrb, "nil");
}

#nil?Boolean

call_seq: nil.nil? -> true

Only the object nil responds true to nil?.

Returns:

  • (Boolean)

69
70
71
72
73
# File 'src/object.c', line 69

static mrb_value
mrb_true(mrb_state *mrb, mrb_value obj)
{
  return mrb_true_value();
}

#to_aArray

Always returns an empty array.

Returns:


13
14
15
16
17
# File 'mrbgems/mruby-object-ext/src/object.c', line 13

static mrb_value
nil_to_a(mrb_state *mrb, mrb_value obj)
{
  return mrb_ary_new(mrb);
}

#to_f0.0

Always returns zero.

Returns:

  • (0.0)

27
28
29
30
31
# File 'mrbgems/mruby-object-ext/src/object.c', line 27

static mrb_value
nil_to_f(mrb_state *mrb, mrb_value obj)
{
  return mrb_float_value(mrb, 0.0);
}

#to_i0

Always returns zero.

Returns:

  • (0)

41
42
43
44
45
# File 'mrbgems/mruby-object-ext/src/object.c', line 41

static mrb_value
nil_to_i(mrb_state *mrb, mrb_value obj)
{
  return mrb_fixnum_value(0);
}

#to_sObject

Always returns the empty string.


83
84
85
86
87
# File 'src/object.c', line 83

static mrb_value
nil_to_s(mrb_state *mrb, mrb_value obj)
{
  return mrb_str_new(mrb, 0, 0);
}

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

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

Overloads:

  • #|(obj) ⇒ Boolean

    Returns:

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

    Returns:

    • (Boolean)

240
241
242
243
244
245
246
247
# File 'src/object.c', line 240

static mrb_value
false_or(mrb_state *mrb, mrb_value obj)
{
  mrb_bool obj2;

  mrb_get_args(mrb, "b", &obj2);
  return mrb_bool_value(obj2);
}