-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
feature/proposalNew feature or requestNew feature or request
Description
This proposal defines not as a regular method, not a keyword or special operator. It enables fluent, English-like syntax while avoiding contextual grammar rules or parser complexity.
Behavior
.notis a method defined on booleans and objects that implement truthiness.- When called, it returns the logical negation of the receiver (
!selfor!to_bool). - It works in any context where boolean negation is expected: conditionals, assignments, expressions, etc.
- It can also be chained fluently to negate the result of a boolean-returning method call.
Examples
if user.not().logged_in?() # reads like: "if user not logged in"
if enabled.not() # negates the boolean value but it's better written as `if not().enabled` with an implicit self at the top level
flag = disabled.not() # assigns the inverse of `disabled`
This avoids the need for a not keyword or ! operator entirely, and eliminates the awkwardness of unless, which many developers mentally rewrite as if not.
Benefits
- ✅ Reads naturally in fluent method chains
- ✅ No special grammar or contextual keywords
- ✅ Uniform:
.not()is just a method - ✅ Works consistently in all boolean contexts
- ✅ Avoids
unless,!, andif notrewrites
Metadata
Metadata
Assignees
Labels
feature/proposalNew feature or requestNew feature or request