Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add public/private per member modifier #911

Merged
merged 4 commits into from
Feb 22, 2022
Merged

Add public/private per member modifier #911

merged 4 commits into from
Feb 22, 2022

Conversation

soutaro
Copy link
Member

@soutaro soutaro commented Feb 22, 2022

This PR introduces public and private visibility modifier syntax, which changes the visibility of a method definition or attribute declaration.

class A
  public                           # The default visibility of members below is `public`

  def foo: () -> void              # A#foo is a public method

  private def self.foo: () -> void # A.foo is a private method

  private                          # The default visibility of members below is `public`

  attr_reader bar: String          # A#bar is a private method

  public attr_accessor baz: String # A#baz and A#baz= are public methods

  public def self?.raise: () -> bot     # Syntax error 🚨
end

@soutaro soutaro merged commit 2ea09d5 into master Feb 22, 2022
@soutaro soutaro deleted the private-public-def branch February 22, 2022 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant