Revision: 4203 http://vexi.svn.sourceforge.net/vexi/?rev=4203&view=rev Author: clrg Date: 2011-08-17 01:29:35 +0000 (Wed, 17 Aug 2011)
Log Message: ----------- Fix boolean docs Modified Paths: -------------- trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSBoolean.java Modified: trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSBoolean.java =================================================================== --- trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSBoolean.java 2011-08-16 23:11:23 UTC (rev 4202) +++ trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSBoolean.java 2011-08-17 01:29:35 UTC (rev 4203) @@ -24,28 +24,52 @@ * * <p>A boolean is a primitive, so all <a href="vexi.js.String.html">string</a> functions are valid.</p> * - * <p>The following values equate to <b><code>false</code></b> when used in boolean operations:<p> + * <h3>Boolean evaluation as false</h3> * + * <p>The following values equate to <b><code>false</code></b> when considered as an expression (e.g. if) result:<p> + * * <ul><li><code>null</code></li> * <li><code>0</code></li> * <li><code>""</code></li></ul> * - * <p>The following values equate to <b><code>true</code></b> when used in boolean operations:<p> + * <p>For example:</p> * + * <pre> if (0) { + * // not reached + * }</pre> + * + * <h3>Boolean evaluation as true</h3> + * + * <p>The following values equate to <b><code>true</code></b> when used in expressions:<p> + * * <ul><li>Any non-<code>null</code> object</li> * <li>Any non-<code>0</code> number</li> * <li>Any non-empty string</li></ul> * + * <p>For example:</p> + * + * <pre> if ("abc") { + * // reached + * }</pre> + * + * <h3>Boolean evaluation as equals</h3> + * + * <p>However, when used in boolean operations as part of the equals (==) operator, values that equate to + * false or true when used in an expression will not usually be considered equal. + * + * <p>The exception to this is <code>0</code> as <code>false</code> is internally stored as a '0', thus + * <code>0 == false</code> evaluates to <code>true</code>. + * * <p>Consider:</p> * - * <pre> 0 == false; - * "0" == true; - * 1 == true; - * -1 == true; - * null == false; - * "null" == true; - * {} == true;</pre> + * <pre> if (null == false) { + * // not reached + * } * + * if ("abc" == true) { + * // not reached + * }</pre> + * * */ //#end return super.get(key); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn