From 35947f6d42705b8f37313a68b03f2f5b846edd6a Mon Sep 17 00:00:00 2001 From: usa Date: Wed, 16 Sep 2015 04:24:31 +0000 Subject: [PATCH] * doc/syntax/literals.rdoc (Strings): mention about ?a literal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ doc/syntax/literals.rdoc | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index f7129956de..7613b25796 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Sep 16 13:23:48 2015 NAKAMURA Usaku + + * doc/syntax/literals.rdoc (Strings): mention about ?a literal. + Wed Sep 16 12:06:53 2015 KOSAKI Motohiro * dir.c (glob_helper): check pathtype once again by lstat(2) if diff --git a/doc/syntax/literals.rdoc b/doc/syntax/literals.rdoc index ec37fe3c6d..2dac68b77a 100644 --- a/doc/syntax/literals.rdoc +++ b/doc/syntax/literals.rdoc @@ -124,6 +124,23 @@ be concatenated as long as a percent-string is not last. %q{a} 'b' "c" #=> "abc" "a" 'b' %q{c} #=> NameError: uninitialized constant q +One more way of writing strings is using ?: + + ?a #=> "a" + +Basically only one character can be placed after ?: + + ?abc #=> SyntaxError + +Exceptionally, \C-, \M- 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