LoginSignup
1
1

More than 3 years have passed since last update.

【ruby】『ruby入門(メモ1)』初めてのrubyプログラム(hello dinosor)+コメント

Posted at

0.はじめに

前回、ruby on railsに超入門したが、文法など何も知らない状態でスタートしていた。
何も基礎的な事を知らないのに、webアプリが作れることはrailsが素晴らしさでもあり、
怖さでもある。
scaffoldから少しでも踏み出すために文法を学ぶつもりだ。

そしてプログラムのどこかに恐竜の名前を出すことも心がけていく。(結構重要)

1.初めてのrubyプログラム

下記はprintで指定した文字列を出力するプログラム

ruby1-1.rb
print("hello dinosor")

2.実行方法

以下コマンドをプログラムのあるディレクトリを入力する。
ruby プログラム名


c:\ruby_pg>ruby ruby1-1.rb
hello dinosor
c:\ruby_pg>

3、コメント記述法(一行)

文字列の前に#を入力するとその行がコメントとみなされる

ruby_comment.rb

#dinosor comment
print("dinosor")

4、コメント記述方法(複数行)

=begin と=endの間に記載された文字列は、コメントとみなされる。

ruby_comment.rb
#下記は複数にわたるコメント
=begin
ティラノサウルス
インドミナスレックス
インドラプトル
これらは全てコメント
=end
print("dinosor2")

5.実行結果

コメント部分は出力されないことがわかる。

c:\ruby_pg>ruby ruby_comment.rb
dinosordinosor2
c:\ruby_pg>

6.参考url

下記場所で学んでいることをアウトプットとして残そうと思う。

1.ruby入門(dotinstall)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1