Project

General

Profile

Feature #7019

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

Added by alexeymuranov (Alexey Muranov) almost 8 years ago. Updated over 2 years ago.

Status:
Rejected
Priority:
Normal
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

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

Also available in: Atom PDF