Project

General

Profile

Actions

Bug #11116

closed

The spec of String#dump

Added by mame (Yusuke Endoh) almost 9 years ago. Updated about 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
[ruby-core:69063]

Description

The current spec says:

 call-seq:
   str.dump   -> new_str

Produces a version of +str+ with all non-printing characters replaced by
<code>\nnn</code> notation and all special characters escaped.

  "hello \n ''".dump  #=> "\"hello \\n ''\"

\nnn must be \xnn now.

In addition, I've expected String#dump to return a string that evaluates to an original string (except singleton methods, object id, etc.) when evaled. Is this a right expectation? If so, it would be good to officially include the mention in the spec. What do you think?

--
Yusuke Endoh

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0