開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの機能制限無料版、light版)
- Script言語:Ruby
『Learning Ruby』(Michael Fitzgerald 著、O'Reilly Media、2007年、ISBN978-0-596-52986-4)の Chapter 6(Arrays)Review Questions 1を解いてみる。
その他参考書籍
- 『プログラミング言語 Ruby』David Flanagan, まつもと ゆきひろ 著 、卜部 昌平 監訳、長尾 高弘 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-394-4)
1.
newと[]
コード(TextWrangler)
#!/usr/bin/env ruby # -*- coding: utf-8 -*- a1 = Array.new(5,10) a2 = Array.[](1,2,3,4,5) [a1,a2].each do |a| p a end
入出力結果(Terminal)
$ ./sample.rb [10, 10, 10, 10, 10] [1, 2, 3, 4, 5] $
0 コメント:
コメントを投稿