Project

General

Profile

Actions

Feature #14951

open

New operator to evaluate truthy/falsy/logical equivalence

Added by danga (Dan Garubba) over 5 years ago. Updated over 5 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:88184]

Description

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) teq.patch prototype implementation danga (Dan Garubba), 07/30/2018 01:35 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0