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

Should focus on String.new not String#initialize. #1789

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

ksss
Copy link
Collaborator

@ksss ksss commented Apr 5, 2024

There is a slight difference in the allowed types between String#initialize and String#new.

The current signature focuses on String#initialize, and includes cases where String.new would fail.

String.new(capacity: nil)
#=> no implicit conversion from nil to integer (TypeError)

There's an option to separate the signatures for String.new and String#initialize, but it's hard to see the benefit of allowing capacity and encoding to be nil.

In this revision, I've changed to a signature that only works with String.new.
I believe this is simpler and more practical.

not `String#initialize`.
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.

👍

I agree testing #initialize method by itself is unnecessary, while it's not too bad if .new is tested. (But it was missing for String...)

@soutaro soutaro added this pull request to the merge queue Apr 6, 2024
@soutaro soutaro added this to the RBS 3.5 milestone Apr 6, 2024
Merged via the queue into ruby:master with commit 7bae527 Apr 6, 2024
17 checks passed
@ksss ksss deleted the string-new branch April 6, 2024 01:44
@soutaro soutaro added the Released PRs already included in the released version label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released PRs already included in the released version
Development

Successfully merging this pull request may close these issues.

2 participants