2016-01-01から1年間の記事一覧

20分ではじめるRubyPico を読む「ファイルからの読み込み」

説明はなかったが、ファイル作成すると以下のコードが挿入されていた。 puts "Hello, RubyPico!" puts "http://rubypico.ongaeshi.me" puts Image.load("chat_ruby.png") これは消して実行すると irb - Interactive Ruby Shell irb:000> load "greeter" => t…

20分ではじめるRubyPico を読む「複数行にまたがるプログラム」

irb - Interactive Ruby Shell irb:000> def hello; puts "Hello World!"; end => :hello irb:001> hello Hello World! => nil irb:002> def hello line 1: syntax error, unexpected $end, expecting ';' or '\n' irb:003> CRubyだと >> def hello >> puts …

20分ではじめるRubyPico を読む「変数の前には@」

「irbで変数を使うときは@を付ける」 irb - Interactive Ruby Shell irb:000> x = 1 => 1 irb:001> x undefined method 'x' for main irb:002> @x = 1 => 1 irb:003> @x => 1 irb:004> 理由不明

動かしてみる

irb - Interactive Ruby Shell irb:000> 1 + 1 => 2 irb:001>