控制结构:

注:Ruby是使用end关键字表明程序体的结束的。

      如果 if 或 while语句的程序体只是一个表达式, Ruby的语句修饰符可以只写出表达式,后面跟着 if 或 while 和条件。

 

 

Test Code:

number = 2
if number<5
  puts "hello, world."
end

 

number = 2

puts "hello, world." if number <5

相关文章:

  • 2021-11-07
  • 2021-12-06
  • 2021-03-31
  • 2022-12-23
  • 2021-12-03
  • 2021-06-25
猜你喜欢
  • 2021-12-29
  • 2021-06-29
  • 2022-12-23
  • 2021-07-07
  • 2021-07-25
  • 2021-05-11
  • 2021-04-28
相关资源
相似解决方案