Project

General

Profile

Actions

Feature #6222

closed

Use ++ to connect statements

Added by gcao (Guoliang Cao) over 12 years ago. Updated over 12 years ago.

Status:
Rejected
Target version:
-
[ruby-core:43858]

Description

I propose to use ++ to connect two or multiple statements, e.g.

do_this ++ do_that ++ do_something

It is equivalent to (do_this; do_that; do_something) but more readable.

It can be used to replace below idiom

do_something and return if condition

with

do_something ++ return if condition

The current way is very error prone because do_something might return false/nil in some cases and cause problems. And new Ruby programmers might not understand the meaning behind this idiom and mimic it blindly.

I noticed someone proposed 'then' for same purpose (See http://bugs.ruby-lang.org/issues/6201) but is postponed to 3.0 because it is already a keyword. I like 'then' too but if it is not acceptable due to backward compatibility issue, then '++' is a good alternative.


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Feature #6201: do_something then return :special_case (include "then" operator)Rejectedmatz (Yukihiro Matsumoto)03/26/2012Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0