今日は筑波大学の問題の34〜36。それほど難しいことはない。しかし、「def」から始まるのはメソッドだと頭では分かっているが、それがどうなる、というのはまだ身体に馴染んでいない。
[Ruby-35]
def max(a, b)
if a > b
return a
else
return b
end
endprint(max(2, 3), "\n")
これは『はじめてのRuby』P.113とほぼ同じ内容だ。本によるとreturnは省略可能だとか。ずいぶんすかすかになってしまいそうなものです。
明日はいよいよ正規表現! 難しそうだが手を動かすのみであります。