I’m not a native English speaker. I know it sounds stupid nonetheless. I write in Python & C. But I can’t quite understand how unless works.
Is it healthy to think of it from a logical standpoint? Eg, consider the if keyword: if condition. If condition is true, the code runs. What’s the logical explanation for unless?
Is there any other way to think of it?
Ruby unless modifier:
Syntax: code unless conditional
Executes code if conditional is false.
Example:
This will produce following result:
1 — Value is set
3 — Value is set