Class: NilClass
- Inherits:
-
Object
- Object
- NilClass
- Defined in:
- src/object.c
Instance Method Summary collapse
-
#& ⇒ Object
And—Returns
false
. -
#^ ⇒ Object
Exclusive Or—If obj is
nil
orfalse
, returnsfalse
; otherwise, returnstrue
. -
#inspect ⇒ Object
15.2.4.3.5.
-
#nil? ⇒ Boolean
call_seq: nil.nil? -> true.
-
#to_a ⇒ Array
Always returns an empty array.
-
#to_f ⇒ 0.0
Always returns zero.
-
#to_h ⇒ Object
Always returns an empty hash.
-
#to_i ⇒ 0
Always returns zero.
-
#to_s ⇒ Object
Always returns the empty string.
-
#| ⇒ Object
Or—Returns
false
if obj isnil
orfalse
;true
otherwise.
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.
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
.
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); } |
#inspect ⇒ Object
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?
.
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_a ⇒ Array
Always returns an empty array.
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_f ⇒ 0.0
Always returns zero.
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_h ⇒ Object
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_i ⇒ 0
Always returns zero.
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_s ⇒ Object
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.
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); } |