小编tim*_*lly的帖子

什么是Ruby lower_bound?

所以我刚刚开始学习Ruby,并且不明白为什么每次我在终端中运行这段代码时输出等于16.对我来说,它没有意义,我真的想从中正确理解语法经验丰富的Rubyist.

def smallest_square(lower_bound)
  i = 0
  while true
    square = i * i

    if square > lower_bound
      return square
    end

    i = i + 1
  end
end

puts(smallest_square(10))
Run Code Online (Sandbox Code Playgroud)

ruby

0
推荐指数
1
解决办法
232
查看次数

标签 统计

ruby ×1