Subscribe to The Madman Scribblings        RSS Feed
-----

False Assumption:- "Comparision" Operators return Booleans

Icon 1 Comments
False Assumption:- "Comparision" Operators return Booleans

It is a popular assumption that "Comparision" Operators = < <= >= > <> will return a Boolean.

This assumption is false. It can be any type.

Since operators are defined by the class the implements them, the semantic meaning of those operators are defined by the implementer of that object.

Relational behind this assumption.

If a < b <= c Then Assumption this should not compile, if a b and c are the same type.

Let's say a, b and c are of type integer.

Integer < Integer <= Integer --> Boolean <= Integer --> Error Operator <= not defined for Boolean and Integer.




Not Photoshopped!?

Attached Image




The truth revealed.
Spoiler

1 Comments On This Entry

Page 1 of 1

pryogene Icon

03 May 2014 - 09:44 AM
Nice post, useful for some of those "head scratching" moments. Just thought I'd point out a typo: "Relational behind this assumption" should read "Rationale behind this assumption".
0
Page 1 of 1

Search My Blog

Recent Entries

Recent Comments