Skip to content

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
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants