Project

General

Profile

Actions

Feature #12519

closed

Expansion of modifier_if and modifier_unless

Added by bk5115545 (Blaise Koch) almost 8 years ago. Updated over 7 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:76147]

Description

Hi all.

I propose a syntax change to allow the below to be valid ruby.

variable = 1 if false else 2

This is an extension of the current modifier_if below which accomplishes the same result.

variable = 1 if false
variable = 2 if !false

keeping up with the other condition-statement keyword the below should be valid as well.

variable = 1 unless true else 2

And is an extension of

variable = 1 unless true
variable = 2 unless !true

While it's true that ternary syntax accomplishes the same task, I feel that the proposed changes are both more readable and a more natural extension of the language.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0