Skip to content

Make protected documentation more explicit about differences #13849

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

Merged
merged 1 commit into from
Jul 17, 2025

Conversation

vinistock
Copy link
Contributor

Protected is a somewhat common source of confusion for devs coming from different languages to Ruby. In languages like Java or TypeScript, it grants access to subclasses for methods.

This is not what it does in Ruby, but it may not be immediately obvious to new developers. If you mark a method as protected because you want subclasses to have access to it, you may never notice the mistake since subclasses already have access to all methods coming from parent classes, including private ones.

I tried to make this aspect of Ruby very explicit in the documentation, in hopes of making it more discoverable and clearer to new developers.

@vinistock vinistock force-pushed the vs_call_more_attention_to_protected branch from 7939336 to 1476979 Compare July 10, 2025 16:53
Protected is a common source of confusion for devs
coming from different languages to Ruby. This
commit makes the documentation more explicit about
the differences, so that the use case for
protected is clearer.
@vinistock vinistock force-pushed the vs_call_more_attention_to_protected branch from 1476979 to b091385 Compare July 10, 2025 17:02
@k0kubun k0kubun merged commit d1f38ce into ruby:master Jul 17, 2025
45 checks passed
@k0kubun k0kubun deleted the vs_call_more_attention_to_protected branch July 17, 2025 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy