CherryRemind 发表于 2013-1-27 05:25:45

21天 Ruby-------

最近一直忙着面试... 现在终于有时间来继续学习ruby了. http://www.agoit.com/images/smiles/icon_smile.gif

ruby中的条件语句
a = 8if a > 0puts "a > 0"elsif a < 0puts "a < 0"elseputs "a == 0"enda = 0str = if a > 0 then "a > 0"elsif a < 0 then "a < 0"else "a == 0"endputs stra = 0puts "a == 0g" if a == 0puts "a == 0h" unless a != 0a = 1case awhen -1    puts "a == -1"when 0    puts "a == 0"when 1    puts "a == 1"else    puts "unknown"enda = "a"case awhen "a"    puts "a == -1"when "b"    puts "a == 0"when "c"    puts "a == 1"else    puts "unknown"enda = 3str = case awhen -10..-1 then "-10 < a < 0"when 0 then "a == 0"when 1..10 then "1 < a < 10"else "unknown"endputs str

<div class="quote_title">引用
页: [1]
查看完整版本: 21天 Ruby-------