[ruby-core:73836] [Ruby trunk Feature#12076][Rejected] The 'ditto' operator

From: matz@...
Date: 2016-02-16 09:43:31 UTC
List: ruby-core #73836
Issue #12076 has been updated by Yukihiro Matsumoto.

Status changed from Open to Rejected

Rejected. Adding new keyword is not a good idea, besides `ditto` behavior is not clear.

Matz.


----------------------------------------
Feature #12076: The 'ditto' operator
https://bugs.ruby-lang.org/issues/12076#change-57012

* Author: Joel Bryan Juliano
* Status: Rejected
* Priority: Normal
* Assignee: 
----------------------------------------
I like to introduce and propose an idea to use a 'ditto' operator in 'else' or 'elsif' statement,
the ditto operator is a reference to the true statement in the if conditions to be used in the proceeding else and elsif statements,
the goal is to reuse the true statement for other conditions also it will make the code to be much readable than recopying and pasting the true statement again.

~~~
if user == "foo"
  puts "welcome" + user  # => welcome foo
elsif user == "bar"
  ditto # => welcome bar
else
  user = "stranger"
  ditto # => welcome stranger
end
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next