AI2's `if` block truthiness check

I've been doing something like this (example):
blocks (4)
where the if block is checking a string-type variable for truthiness.

However, I just realized that I do not know if AI2 does type coercion if at all. I accidentally made a number of these checks unconsciously coming from an ECMAScript background...so my project is littered with these.

So, does App Inventor 2 do any sort of type coercion, or will the resulting app crash when it tries to check for a bool value in a non-bool input?

Your methodology have logical error

Better try like this to avoid the app crash
This triggers the input as String

Screenshot 2025-05-03 094741

This triggers the given input as Number

Screenshot 2025-05-03 094849

1 Like

Thank you for the answer. I would use explicit type checking from now on

1 Like