Indeed, `if x!=0` is so much more self-explanatory than `if bool(x)`.

Friedrich, I believe `if 5` "has to work" in C since C has no native 
booleans (`a==b` returns an int).

On Saturday, April 5, 2014 11:59:14 PM UTC+1, Stefan Karpinski wrote:
>
> You have a point – the bool function is meaningless and should be deleted. 
> If you want to turn a value into a boolean, there are many specific ways to 
> do so.
>
> On Apr 5, 2014, at 6:21 PM, [email protected] <javascript:> wrote:
>
>
> bool(5) is true
> and bool(0) is false
> (and bool(None) doesn't work in contrast to python)
>
> So in Julia, C, and Python it is the same.
>
> But unfortunately the "if" statement in Julia does not make the boolean 
> conversion.
>
>
> I know that `if 5` works in Python and in C. Many languages choose to make 
>> `0` ¨truthy¨ and all other values ¨falsey¨, meaning that they are used as 
>> true/false despite not being booleans. It is by design that this doesn't 
>> work in Julia.
>>
>> -- Leah
>>
>

Reply via email to