[OpenSCAD] if statement ignores non boolean values

nop head nop.head at gmail.com
Sat Sep 17 18:06:57 CEST 2011


If it only handles boolean values it should complain if it gets
something that is not one or it should convert it to a boolean like
any other language.

On 17 September 2011 16:49, William Adams <william_a_adams at msn.com> wrote:
> Why would it complain?  I thought OpenScad has 'true' and 'false', actual
> boolean values.  In this context, 1 != true.
>
> so
> if (1)
>   echo(true);
> else
>   echo(false);
>
> will echo: false
>
> That seems like 'correct' behavior, if a bit annoying to classical 'C'
> programmers.
>
> -- William
>
> ===============================
> - Shaping clay is easier than digging it out of the ground.
>
>
> http://internationalwilliam.spaces.msn.com/
>
>
>> Date: Sat, 17 Sep 2011 16:06:35 +0100
>> From: nop.head at gmail.com
>> To: openscad at rocklinux.org
>> Subject: [OpenSCAD] if statement ignores non boolean values
>>
>> if(1) { ... } is not treated as true but does not complain either. A
>> bit confusing as I can't think of another language that would not do
>> one of the other.
>> _______________________________________________
>> OpenSCAD mailing list
>> OpenSCAD at rocklinux.org
>> http://rocklinux.net/mailman/listinfo/openscad
>
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org
> http://rocklinux.net/mailman/listinfo/openscad
>
>


More information about the OpenSCAD mailing list