Class: NilClass

Inherits:
Object
  • 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_frozen(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:



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

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)


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

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

#to_hObject

Always returns an empty hash.



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

static mrb_value
nil_to_h(mrb_state *mrb, mrb_value obj)
{
  return mrb_hash_new(mrb);
}

#to_i0

Always returns zero.

Returns:

  • (0)


55
56
57
58
59
# File 'mrbgems/mruby-object-ext/src/object.c', line 55

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_frozen(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);
}