Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@BurdetteLamar
Copy link
Member

No description provided.

@BurdetteLamar BurdetteLamar added the Documentation Improvements to documentation. label Nov 13, 2025

In the simplest case, the dumped string contains the original string,
enclosed in double-quotes;
this example is done in +irb+ (interactive Ruby):
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why we need to specify that this example is in IRB?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed (enough?).


Keep in mind that in the second line above:

- The outer double-quotes are put on by +irb+,
Copy link
Member

Choose a reason for hiding this comment

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

IRB just outputs the value of the #inspect method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

def dump(s)
$stdout.write ' String: '; puts s
$stdout.write ' Dumped: '; puts s.dump
$stdout.write ' Undumped: '; puts s.dump.undump
Copy link
Member

Choose a reason for hiding this comment

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

Also, this is the documentation for String#dump, should we even show String#undump? I don't think that's relevant.

Copy link
Member Author

Choose a reason for hiding this comment

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

You can't (sensibly) undump just anything; it makes sense only for a dumped string. Therefore I've just linked here from undump, so both can be discussed together.

Comment on lines 34 to 36
String: hello
Dumped: "hello"
Undumped: hello
Copy link
Member

Choose a reason for hiding this comment

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

Should we put all the output in a comment? I don't think syntax highlighting will be happy about invalid Ruby syntax.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've omitted the calls to the helper, and just shown the output. See how you like it.

Comment on lines 49 to 56
In a dump, unprintable characters are replaced by printable ones
(\String and Undumped are omitted here, because they are all whitespace):

s = ''
(7..13).each {|i| s << i }
# => 7..13
dump(s)
Dumped: "\a\b\t\n\v\f\r"
Copy link
Member

Choose a reason for hiding this comment

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

In this case, can this example just simply not use the dump method?

(\String and Undumped are omitted here, because they are all whitespace):

s = ''
(7..13).each {|i| s << i }
Copy link
Member

Choose a reason for hiding this comment

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

It would be useful to list what these values mean like in the previous example.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I like what I've added here.

@BurdetteLamar
Copy link
Member Author

@peterzhu2118, all comments addressed, I think.

string.c Outdated
* Related: String#dump (inverse of String#undump).
* undump -> new_string
*
* See String#dump.
Copy link
Member

Choose a reason for hiding this comment

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

I think we should still have a brief description for undump, we can't just have documentation that links to the inverse.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added; also touched up in "What's Here."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements to documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants