ruby文件打开和关闭

后端开发   发布日期:2025年06月15日   浏览次数:88

class File

  def File.Open(*args)

    result=f=File.new(*args)

    if block_given?

    begin

      result=yield f

    ensure

      f.close

    end

    return result

  end

end

 

注: ensure用于必定要执行的语句

以上就是ruby文件打开和关闭的详细内容,更多关于ruby文件打开和关闭的资料请关注九品源码其它相关文章!