编辑代码

#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。

x = 0
if x > 2
   puts "x bigger than 2"
elsif x == 2
   puts "x equals 2"
else
   puts "x less than 2"
end
# Output: x less than 2

x = 0
unless x > 2
   puts "x less than 2"
 else
   puts "x bigger than 2"
end
# Output: x less than 2

i = 0
while i < 2 do
   i = i + 1
   puts "i less than 2"
end