From: mame@... Date: 2018-07-31T01:26:16+00:00 Subject: [ruby-core:88224] [Ruby trunk Feature#14951] New operator to evaluate truthy/falsy/logical equivalence Issue #14951 has been updated by mame (Yusuke Endoh). How about defining a helper function for your assertions? ``` def assert_same_as_boolean(x, y) raise MyError unless !x == !y end assert_same_as_boolean(in_scenario_x?, actions_performed_for_scenario_x?) ``` It would be a good idea to avoid introducing a new operator without true necessity. ---------------------------------------- Feature #14951: New operator to evaluate truthy/falsy/logical equivalence https://bugs.ruby-lang.org/issues/14951#change-73243 * Author: danga (Dan Garubba) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- I propose adding a new operator for truthy/falsy equivalence, similar to what was proposed on https://bugs.ruby-lang.org/issues/13067, but with new syntax. The main purpose would be for writing expressions for logical equivalence (i.e., "if and only if" relationships) that only considers the truthiness the operands. Since predicate methods like `File#size?` and operators like `=~` follow truthy semantics without returning the `true` and `false` singletons, using them in logical expressions that evaluate for logical equivalence can be error-prone without the proper return type awareness and conversions. This proposed operator would be equivalent to `!!a == !!b`, but I feel that a new operator would be more concise and more expressive of the concept of logical equivalence. Attached is a prototype implementation of the operator as '=?'. ---Files-------------------------------- teq.patch (3.47 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: