-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[DOC] Tweaks for String.new #13027
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
base: master
Are you sure you want to change the base?
[DOC] Tweaks for String.new #13027
Conversation
doc/string/new.rdoc
Outdated
s0 = 'foo'.encode(Encoding::UTF_16) | ||
s1 = String.new(s0) | ||
s1.encoding # => #<Encoding:UTF-16 (dummy)> | ||
s0 = ''.encode(Encoding::UTF_16) | ||
s1 = String.new(s0) | ||
s1.encoding # => #<Encoding:UTF-16 (dummy)> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two examples seems to be showing the exact same thing? What's the second example showing?
the +encoding+ may be an Encoding object, an encoding name, | ||
or an encoding name alias: | ||
|
||
String.new(encoding: Encoding::US_ASCII).encoding # => #<Encoding:US-ASCII> | ||
String.new('', encoding: Encoding::US_ASCII).encoding # => #<Encoding:US-ASCII> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this example? It doesn't seem to be showing anything new.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to show that the default empty string is different from as passed empty string. I have removed the example and changed the call-seq.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the default empty string is different from a passed in empty string? It works the same when you specify an encoding
.
the +encoding+ may be an Encoding object, an encoding name, | ||
or an encoding name alias: | ||
|
||
String.new(encoding: Encoding::US_ASCII).encoding # => #<Encoding:US-ASCII> | ||
String.new('', encoding: Encoding::US_ASCII).encoding # => #<Encoding:US-ASCII> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the default empty string is different from a passed in empty string? It works the same when you specify an encoding
.
string.c
Outdated
/* | ||
* | ||
* call-seq: | ||
* String.new(string = '', **opts) -> new_string | ||
* String.new(string = ''.encode(Encoding::ASCII_8BIT)) , **options) -> new_string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* String.new(string = ''.encode(Encoding::ASCII_8BIT)) , **options) -> new_string | |
* String.new(string = ''.encode(Encoding::ASCII_8BIT) , **options) -> new_string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
But when option |
@peterzhu2118, are there still open issues here? |
@peterzhu2118, will you be reviewing this? |
No description provided.