ruby debug method object.tap

作用有点类似linux中的tee命令:

class Object  def tap    yield self    self  endend

usage of linux command: tee

 ps -ef |grep httpd|tee > grep_result |awk -f " " '{print $1}'|wc -l

其中tee > file是将前一个命令输出的结果打到文件里以方便查看结果。

use tee in vim

:w !sudo tee %

这个是vim中以普通用户编辑文件时,无法保存,可以用vi的!{cmd}指令调用tee进行文件同名%保存w操作。