Luaプログラミング入門 > 第2章 Lua言語の基礎 > 例題 > 長文を表示するプログラム


[Prev] [Next] [Up] [Contents][フレーム表示] [フレーム解除

長文を表示するプログラム 応援する 

一行で表示する文字数が多い場合それを同じライン上で書くとコードが読みにくくなる場合があります.

この場合の修正方法を学んでいきましょう.

print関数を一回だけ使い,

 There are 10 types of people in this world. Those who understand binary and those who don't. Which one are you? 

という文章を表示するとしましょう.

しかし同じライン上で書くとコードが読みにくくなってしまいます. この場合以下のようにコードを書くこともできます.

--この用にコードを書くこともできる
print("There are 10 types of people in this world." ..
        "Those who understand binary and those who don't." ..
        "Which one are you?" )

..という部分に注目してください.

これは複数の文字列をつなぎ合わせるときに使用します. 詳細は次章で説明します.

実行結果
There are 10 types of people in this world.Those who understand binary and those who don't.Which one are you?

[Prev] [Next] [Up] [Contents][フレーム表示] [フレーム解除

このサイトについて|ヘルプ|Q&A|個人情報保護|プライバシーポリシー|利用規約|コメント・トラックバック規約|削除規程|広告掲載
Copyright (c) 2005-2007 Time Intermedia Corporation