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

Document a few details about class #2174

Merged
merged 1 commit into from
Jan 25, 2025
Merged

Conversation

Morriar
Copy link
Contributor

@Morriar Morriar commented Dec 17, 2024

Following the discussion in #2139 (comment).

@ParadoxV5
Copy link
Contributor

class refers to the class itself. From my understanding,

class A
  X: class # A
end
class B < A
  # B::X is of type B
end

I’ve always considered instance and self to be different:

SUBJECT = Object.new
SUBJECT.extend Comparable # i.e., SUBJECT.singleton_class.include Comparable
class Object
  def dup: () -> instance # Object
  def itself: () -> self # Object
end
SUBJECT: Object & Comparable
# SUBJECT.dup    -> Object
# SUBJECT.itself -> Object & Comparable

@soutaro
Copy link
Member

soutaro commented Jan 24, 2025

Thanks. Looks good.

I found the biggest difference is when the class is generic. When the type is C[Integer], self is C[Integer], instance is C[untyped].

Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@soutaro soutaro enabled auto-merge January 24, 2025 03:23
Signed-off-by: Alexandre Terrasa <[email protected]>
auto-merge was automatically disabled January 24, 2025 14:54

Head branch was pushed to by a user without write access

@Morriar
Copy link
Contributor Author

Morriar commented Jan 24, 2025

Rebased on master 👍

@soutaro soutaro added this pull request to the merge queue Jan 25, 2025
Merged via the queue into ruby:master with commit e5a4329 Jan 25, 2025
19 checks passed
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.

3 participants