What is GNU?
GNUは何の略かに答えてみた.
プログラム
- what_is_GNU.rb
def what_is_GNU(num = 0) gnu = "GNU is Not UNIX" 1.upto(num) do gnu = "(#{gnu}) is Not UNIX" end puts "GNU = #{gnu}\n\n" end 0.upto(10) do |index| puts "Do you know what is GNU? (y/n)" ans = gets.chomp if ans == 'y' puts "Great!\n" break elsif ans == 'n' what_is_GNU index else puts "Please type 'y' or 'n'!\n\n" end end
実行結果
% ruby what_is_GNU.rb Do you know what is GNU? (y/n) n GNU = GNU is Not UNIX Do you know what is GNU? (y/n) n GNU = (GNU is Not UNIX) is Not UNIX Do you know what is GNU? (y/n) y Great!