所以我刚刚开始学习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 ×1