[前][次][番号順一覧][スレッド一覧]

ruby-changes:39794

From: knu <ko1@a...>
Date: Wed, 16 Sep 2015 15:17:07 +0900 (JST)
Subject: [ruby-changes:39794] knu:r51875 (trunk): [DOC] Revise the character literal part.

knu	2015-09-16 15:16:15 +0900 (Wed, 16 Sep 2015)

  New Revision: 51875

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51875

  Log:
    [DOC] Revise the character literal part.

  Modified files:
    trunk/ChangeLog
    trunk/doc/syntax/literals.rdoc
Index: doc/syntax/literals.rdoc
===================================================================
--- doc/syntax/literals.rdoc	(revision 51874)
+++ doc/syntax/literals.rdoc	(revision 51875)
@@ -147,22 +147,22 @@ be concatenated as long as a percent-str https://github.com/ruby/ruby/blob/trunk/doc/syntax/literals.rdoc#L147
   %q{a} 'b' "c" #=> "abc"
   "a" 'b' %q{c} #=> NameError: uninitialized constant q
 
-One more way of writing strings is using <tt>?</tt>:
-
-  ?a #=> "a"
-
-Basically only one character can be placed after <tt>?</tt>:
-
-  ?abc #=> SyntaxError
-
-Exceptionally, <tt>\C-</tt>, <tt>\M-</tt> and their combination are allowed
-before a character.  They mean "control", "meta" and "control-meta"
-respectively:
-
+There is also a character literal notation to represent single
+character strings, which syntax is a question mark (<tt>?</tt>)
+followed by a single character or escape sequence that corresponds to
+a single codepoint in the script encoding:
+
+  ?a       #=> "a"
+  ?abc     #=> SyntaxError
+  ?\n      #=> "\n"
+  ?\s      #=> " "
+  ?\\      #=> "\\"
+  ?\u{41}  #=> "A"
   ?\C-a    #=> "\x01"
   ?\M-a    #=> "\xE1"
   ?\M-\C-a #=> "\x81"
   ?\C-\M-a #=> "\x81", same as above
+  ?     #=> "
 
 === Here Documents
 
@@ -350,4 +350,3 @@ one of the array entries you must escape https://github.com/ruby/ruby/blob/trunk/doc/syntax/literals.rdoc#L350
 If you are using "(", "[", "{", "<" you must close it with ")", "]", "}", ">"
 respectively.  You may use most other non-alphanumeric characters for percent
 string delimiters such as "%", "|", "^", etc.
-
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51874)
+++ ChangeLog	(revision 51875)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Sep 16 15:08:17 2015  Akinori MUSHA  <knu@i...>
+
+	* doc/syntax/literals.rdoc (Strings): [DOC] Revise the character
+	  literal part.
+
 Wed Sep 16 14:55:33 2015  Akinori MUSHA  <knu@i...>
 
 	* doc/syntax/literals.rdoc (Strings): [DOC] Document the full list

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]