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

ruby-changes:39790

From: usa <ko1@a...>
Date: Wed, 16 Sep 2015 13:24:59 +0900 (JST)
Subject: [ruby-changes:39790] usa:r51871 (trunk): * doc/syntax/literals.rdoc (Strings): mention about ?a literal.

usa	2015-09-16 13:24:31 +0900 (Wed, 16 Sep 2015)

  New Revision: 51871

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

  Log:
    * doc/syntax/literals.rdoc (Strings): mention about ?a literal.

  Modified files:
    trunk/ChangeLog
    trunk/doc/syntax/literals.rdoc
Index: doc/syntax/literals.rdoc
===================================================================
--- doc/syntax/literals.rdoc	(revision 51870)
+++ doc/syntax/literals.rdoc	(revision 51871)
@@ -124,6 +124,23 @@ be concatenated as long as a percent-str https://github.com/ruby/ruby/blob/trunk/doc/syntax/literals.rdoc#L124
   %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 means "control", "meta" and "control-meta"
+respectively:
+
+  ?\C-a    #=> "\x01"
+  ?\M-a    #=> "\xE1"
+  ?\M-\C-a #=> "\x81"
+  ?\C-\A-a #=> "\x81", same as above
+
 === Here Documents
 
 If you are writing a large block of text you may use a "here document" or
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51870)
+++ ChangeLog	(revision 51871)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Sep 16 13:23:48 2015  NAKAMURA Usaku  <usa@r...>
+
+	* doc/syntax/literals.rdoc (Strings): mention about ?a literal.
+
 Wed Sep 16 12:06:53 2015  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* dir.c (glob_helper): check pathtype once again by lstat(2) if

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

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