>> denim_ge...@hotmail.com wrote:
>>> Why is the following true?:
[quoted text clipped - 12 lines]
>
> dinosaur == true ?
It's false. I don't care about your answer key. Get a compiler and try
it, or better yet learn the language.
Your latest one here is wrong too, ints aren't even comparable to booleans.:
init:
deps-jar:
Compiling 1 source file to
C:\Users\Brenden\Dev\misc\FinalizeTest\build\classes
C:\Users\Brenden\Dev\misc\FinalizeTest\src\finalizetest\Main.java:31:
incomparable types: int and boolean
if( dinosaur == true )
1 error
BUILD FAILED (total time: 2 seconds)
denim_genes@hotmail.com - 13 Apr 2008 08:04 GMT
> denim_ge...@hotmail.com wrote:
> >> denim_ge...@hotmail.com wrote:
[quoted text clipped - 28 lines]
> 1 error
> BUILD FAILED (total time: 2 seconds)
I know the language, hence why I was confused as to this "reliable"
answer key.
Arved Sandstrom - 13 Apr 2008 15:30 GMT
>>> denim_ge...@hotmail.com wrote:
>>>> Why is the following true?:
[quoted text clipped - 18 lines]
> Your latest one here is wrong too, ints aren't even comparable to
> booleans.:
[ SNIP ]
This question brings up the always popular programming trivia contest...what
are the truth values in various programming languages? Not always easy to
remember...
For example, in awk "0" is true because it's a non-null string value.
However, in Perl "0" is false (but "0.0" is true). Apparently in REBOL the
integer 0 is true.
Does the language in question (1) use two boolean values, or (2) does it
define truth values for all values of datatypes, or (3) does it define two
boolean values *and* also truth values for values of other datatypes?
Example of #3 being Javascript.
Then there's the convention in UNIX that a program is considered to have
succeeded if it sets an exit code of 0, which can catch the novice shell
script programmer by surprise...
I think there was an attempt to design a bool class in C++ quite some back
but they couldn't quite design one that was completely correct, hence the
bool datatype. Of course you can still initialize a bool with 0...
AHS
Roedy Green - 24 Apr 2008 10:04 GMT
On Sat, 12 Apr 2008 23:18:07 -0700, Mark Space
<markspace@sbc.global.net> wrote, quoted or indirectly quoted someone
who said :
>I don't care about your answer key.
Sounds like that Monty Python English phrase book for Bulgarians.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
>dinosaur == true ?
That is equivalent to asking if 1 is true. It is a meaningless
question in Java.. In C, any int != 0 is considered true. In java an
int has no meaning as a boolean.
You would have to say something like
int dinosaur;
...
boolean isBaby = dinosaur < 1;
which might or might not be true.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com