Peña, Botp
10/30/2004 5:48:00 AM
//I still don't see a reason for #true? and #false?.
it's a language problem. ruby caters english and sometimes the language does
not fall immediately into ones (non-english) ears... Thus the op was asking
if he could be more explicit+...
consider:
a = (1 > 0)
if a
block
end
At a first glance (assumming sans k on progg lang), one has to know
semantics of if. And here, one realizes that block executes if a is true.
now consider:
if a.true?
block
end
Surely, one can deduce that block will execute if a is true.
and
if a.false?
block
end
Surely, one can deduce that block will execute if a is false. One does not
need to bend mind just to say "if not a". Why would one want to say "not
true" when he can say "false"?
And besides,
"if a" does not look o-o to me (only).
"if a.is_a" or "if a.kind_of" looks o-o.
also
irb(main):010:0> p a.methods
["send", "&", "object_id", "singleton_methods", "__send__", "equal?",
"taint", "frozen?", "instance_variab
le_get", "kind_of?", "to_a", "instance_eval", "type", "protected_methods",
"extend", "|", "eql?", "instanc
e_variable_set", "hash", "is_a?", "to_s", "class", "tainted?",
"private_methods", "^", "untaint", "id", "i
nspect", "==", "===", "clone", "public_methods", "respond_to?", "display",
"freeze", "__id__", "=~", "meth
ods", "method", "nil?", "dup", "instance_variables", "instance_of?"]
a is really an object.
so "if a" is asking like "is a an object" ??
Btw, in our local dialect, we do not have an "if a" counterpart, so you can
understand our slight predicament :-|
kind regards -botp