bash-oo-framework icon indicating copy to clipboard operation
bash-oo-framework copied to clipboard

False boolean not working

Open jasontcs opened this issue 6 years ago • 1 comments

The following error occurred

boolean trueVar=true $var:trueVar toString #true

boolean falseVar=false $var:falseVar toString #UNCAUGHT EXCEPTION: toString

Is it a bug? Or is my implementation incorrect?

jasontcs avatar Mar 21 '19 08:03 jasontcs

Actually toString of false boolean is implemented so that it behaves like false:

https://github.com/niieani/bash-oo-framework/blob/0276ffad26cabd5ce29f18b4ca87fbc01bc630ab/lib/TypePrimitives/boolean.sh#L15

The return code of false is 1, which means it's treated like an exception.

Probably might sense to change how boolean toString works cause it's unintuitive right now. I don't remember what was the reason I did it like this. I think it's so that invoking that variable would behave similarly to invoking true or false and so that one could use this in comparisons or logic.

niieani avatar Mar 23 '19 14:03 niieani