開発環境
- OS X El Capitan - Apple (OS)
- Emacs (Text Editor)
- Ruby 2.3 (プログラミング言語)
Head First Ruby (Jay McGavren (著)、O'Reilly Media)のChapter 11.(Documentation Read the Manual)、How the Comparable methods work、POOL PUZZLE(No. 5804)を取り組んでみる。
POOL PUZZLE(No. 5804)
コード(Emacs)
#!/usr/bin/env ruby2.3
# -*- coding: utf-8 -*-
array = [10, 5, 7, 3, 9]
first = array.shift
puts "We pulled #{first} off the start of the array."
last = array.pop
puts "We pulled #{last} off the end of the array."
largest = array.max
puts "The largest remaining number is #{largest}."
入出力結果(Terminal)
$ ./sample1.rb We pulled 10 off the start of the array. We pulled 9 off the end of the array. The largest remaining number is 7. $
0 コメント:
コメントを投稿