昊天SEO

练习29: 如果(if)–笨方法学ruby在线

这里是你接下要写的作业,这段介绍了if-statement (if 语句)。把这段输入进去,让它能够正确执行。然后我们看看你是否有收获。

people = 20
cats = 30
dogs = 15

if people < cats
  puts "Too many cats! The world is doomed!"
end

if people > cats
  puts "Not many cats! The world is saved!"
end

if people < dogs
  puts "The world is drooled on!"
end

if people > dogs
  puts "The world is dry!"
end

dogs += 5

if people >= dogs
  puts "People are greater than or equal to dogs."
end

if people <= dogs
  puts "People are less than or equal to dogs."
end

if people == dogs
  puts "People are dogs."
end

本文地址官网    新乡网站建设,seo

分享到:更多 ()