ruby系列教材(25):Blocks for Transactions

上一篇 / 下一篇  2008-02-02 15:28:37 / 个人分类:Ruby

事务(transaction)决定了一段代码要么一起运行,要么一句也不运行

 

class File

  def File.open_and_process(*args)

    f = File.open(*args)

    yield f

    f.close()

  end

end

 

File.open_and_process("testfile","r") do |f|

  while line = f.gets

    puts line

  end

end

 

 

......未完


TAG: Ruby

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-06  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 22868
  • 日志数: 47
  • 建立时间: 2008-01-29
  • 更新时间: 2008-02-02

RSS订阅

Open Toolbar