Project

General

Profile

Actions

Feature #7019

closed

allow `private` and `protected` keywords to take blocks

Added by alexeymuranov (Alexey Muranov) about 12 years ago. Updated almost 7 years ago.

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

Description

I like to indent my private methods one level deeper, but this indentation is inconsistent with the syntax:

class C
  def f
    #
  end
  private
    def g
    #
    end
end

I think it would be nice if the private keyword could take a block, then i would write:

class C
  def f
    #
  end
  private do
    def g
    #
    end
  end
end

Related issues 2 (1 open1 closed)

Has duplicate Ruby master - Feature #8497: private, protected, private_constなどがブロックを受け取るようにするRejectedmatz (Yukihiro Matsumoto)Actions
Has duplicate Ruby master - Feature #16276: For consideration: "private do...end" / "protected do...end"OpenActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0