发布于 2017-12-20 07:39:04
喜欢这个:
people = []
begin
info = gets.chomp
people += [Person.new(info)] if not info.empty?
end while not info.empty?
发布于 2017-12-20 07:37:57
该begin <code> end while <condition>由Ruby的作者Matz的拒绝。相反,他建议使用Kernel#loop,例如
loop do
# some code here
break if <condition>
end
相似问题
领取专属 10元无门槛券
AI混元助手 在线答疑
洞察 腾讯核心技术
剖析业界实践案例