Class: TrueClass

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

Instance Method Summary collapse

Instance Method Details

#&(obj) ⇒ Boolean

And—Returns false if obj is nil or false, true otherwise.

Returns:

  • (Boolean)


147
148
149
150
151
152
153
154
155
# File 'mruby/src/object.c', line 147

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

  mrb_get_args(mrb, "b", &obj2);

  return mrb_bool_value(obj2);
}

#^(obj) ⇒ Object

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



167
168
169
170
171
172
173
174
# File 'mruby/src/object.c', line 167

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

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

#to_sObject

The string representation of true is “true”.



184
185
186
187
188
189
190
# File 'mruby/src/object.c', line 184

static mrb_value
true_to_s(mrb_state *mrb, mrb_value obj)
{
  mrb_value str = mrb_str_new_lit_frozen(mrb, "true");
  RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
  return str;
}

#to_sObject

The string representation of true is “true”.



184
185
186
187
188
189
190
# File 'mruby/src/object.c', line 184

static mrb_value
true_to_s(mrb_state *mrb, mrb_value obj)
{
  mrb_value str = mrb_str_new_lit_frozen(mrb, "true");
  RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
  return str;
}

#|(obj) ⇒ true

Or—Returns true. As anObject is an argument to a method call, it is always evaluated; there is no short-circuit evaluation in this case.

true |  puts("or")
true || puts("logical or")

produces:

or

Returns:

  • (true)


209
210
211
212
213
# File 'mruby/src/object.c', line 209

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