简单教程
提交运行
代码编辑器:
# !/usr/bin/ruby -w # -*- encoding:utf-8 -*- # filename: main.rb # author: 简单教程(www.twle.cn) # Copyright © 2015-2065 www.twle.cn. All rights reserved. $age = 5 puts "age = #$age" case $age when 0 .. 2 puts "婴儿" when 3 .. 6 puts "小孩" when 7 .. 12 puts "child" when 13 .. 18 puts "少年" else puts "其他年龄段的" end
运行结果: