aboutsummaryrefslogtreecommitdiffhomepage
path: root/content/posts/2021-10-02/ruby-then-keyword-and-case-in.xml
diff options
context:
space:
mode:
Diffstat (limited to 'content/posts/2021-10-02/ruby-then-keyword-and-case-in.xml')
-rw-r--r--content/posts/2021-10-02/ruby-then-keyword-and-case-in.xml14
1 files changed, 9 insertions, 5 deletions
diff --git a/content/posts/2021-10-02/ruby-then-keyword-and-case-in.xml b/content/posts/2021-10-02/ruby-then-keyword-and-case-in.xml
index c3fd933..4176c67 100644
--- a/content/posts/2021-10-02/ruby-then-keyword-and-case-in.xml
+++ b/content/posts/2021-10-02/ruby-then-keyword-and-case-in.xml
@@ -63,11 +63,15 @@ end</programlisting>
を書くことはない。なぜか。次のコードを実行してみるとわかる。</simpara>
<programlisting language="ruby" linenumbering="unnumbered">if true puts 'Hello, World!' end</programlisting>
<simpara>次のような構文エラーが出力される。</simpara>
- <literallayout class="monospaced">20:1: syntax error, unexpected local variable or method, expecting `then' or ';' or '\n'
- if true puts 'Hello, World!' end
- ^~~~
- 20:1: syntax error, unexpected `end', expecting end-of-input
- ...f true puts 'Hello, World!' end</literallayout>
+ <literallayout class="monospaced">
+ <![CDATA[
+ 20:1: syntax error, unexpected local variable or method, expecting `then' or ';' or '\n'
+ if true puts 'Hello, World!' end
+ ^~~~
+ 20:1: syntax error, unexpected `end', expecting end-of-input
+ ...f true puts 'Hello, World!' end
+ ]]>
+ </literallayout>
<simpara>二つ目のメッセージは無視して一つ目を読むと、<literal>then</literal> か <literal>;</literal>
か改行が来るはずのところ変数だかメソッドだかが現れたことによりエラーとなっているようだ。</simpara>
<simpara>ポイントは改行が <literal>then</literal> (や <literal>;</literal>) の代わりとなることである。<literal>true</literal>