Project

General

Profile

Actions

Feature #5054

closed

Compress a sequence of ends

Added by technohippy (Yasushi ANDO) over 13 years ago. Updated over 8 years ago.

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

Description

Though as matz said at rubykaigi2011 ruby is a quite good language, many people hate a long sequence of end like this:

module MyModule
  class MyClass
    def my_method
      10.times do
        if rand < 0.5 
          p :small
        end 
      end 
    end 
  end 
end

So, I'd like to propose introducing a special keyword, en(n+)d. Using this keyword, we can rewrite the above example like this:

module MyModule
  class MyClass
    def my_method
      10.times do
        if rand < 0.5 
          p :small
        ennnnnd 

I know matz's already rejected a python-style block. He wrote:

it works badly with

These bad things won't occur by introducing en(n+)d.

Some implementations already exists.

JRuby

CRuby

Thanks for your consideration.


Related issues 4 (1 open3 closed)

Related to Ruby master - Feature #5065: Allow "}" as an alternative to "end"RejectedActions
Related to Ruby master - Feature #12241: super endRejectedActions
Related to Ruby master - Feature #16746: Endless method definitionClosednobu (Nobuyoshi Nakada)Actions
Has duplicate Ruby master - Feature #17786: Proposal: new "ends" keywordOpenActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like1Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0