From ab3756b76fe2543155091d08226cd6d7d41f713f Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 27 Apr 2026 10:23:13 -0400 Subject: [PATCH] Clarify truthiness definitions in logical operators Updated definitions to clarify that truthiness is based on JavaScript's definition instead of Handlebars'. --- text/0562-add-logical-operators.md | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/text/0562-add-logical-operators.md b/text/0562-add-logical-operators.md index 1ea5edf2bd..3f8057e6f4 100644 --- a/text/0562-add-logical-operators.md +++ b/text/0562-add-logical-operators.md @@ -42,29 +42,17 @@ Add `{{and}}`, `{{or}}` and `{{not}}` helpers. #### `{{and}}` Takes at least two positional arguments. Raises an error if invoked with less than two arguments. -It evaluates arguments left to right, returning the first one that is not _truthy_ (**by handlebar's definition of truthiness**) +It evaluates arguments left to right, returning the first one that is not _truthy_ (**by javascript's definition of truthiness**) or the right-most arguments if **all** evaluate to _truthy_. -This is *NOT* equivalent to the `{{and}}` helper from `ember-truth-helpers` because unlike this proposed helper, the one in `ember-truth-helpers` -uses Javascript's definition of truthiness. #### `{{or}}` Takes at least two positional arguments. Raises an error if invoked with less than two arguments. -It evaluates arguments left to right, returning the first one that is _truthy_ (**by handlebar's definition of truthiness**) or the +It evaluates arguments left to right, returning the first one that is _truthy_ (**by javascript's definition of truthiness**) or the right-most argument if all evaluate to _falsy_. -This is *NOT* equivalent to the `{{or}}` helper from `ember-truth-helpers` because unlike this proposed helper, the one in `ember-truth-helpers` -uses Javascript's definition of truthiness. #### `{{not}}` Unary operator. Raises an error if invoked with more than one positional argument. If the given value evaluates to a _truthy_ value (**by handlebar's definition of truthiness**), -the `false` is returned. If the given value evaluates to a _falsy_ value (**by handlebar's definition of truthiness**) then it returns `true`. -This is *NOT* equivalent to the `{{not}}` helper from `ember-truth-helpers` because unlike this proposed helper, the one in `ember-truth-helpers` -uses Javascript's definition of truthiness. - -#### Handlebar's definition of truthiness -This is the most important detail of this proposal because it's where it deviates from `ember-truth-helpers`. -Handlebars has its own definition of _truthyness_, which is similar to Javascripts except that empty arrays are -considered **falsy**, while in JS are considered **truthy**. - +the `false` is returned. If the given value evaluates to a _falsy_ value (**by javascript's definition of truthiness**) then it returns `true`. This RFC intentionally leaves the implementation details unspecified, but one can think of those helpers as macros that expand to combinations of `if`s.