From: "Mauricio Fernández" Date: 2003-04-24T17:18:38+09:00 Subject: Re: grep and regular expressions in ruby On Thu, Apr 24, 2003 at 04:44:50PM +0900, Brian Candler wrote: > Somebody once did propose, and I think even implement, a default object > receiver: something like > > while line = gets > with line do > chomp! > gsub!(/foo/,'bar') > # etc > end > end > > For the duration of the block, *self* is set to 'line'. That IMO is much > more Rubyish than having a bunch of methods all act on the shared global > variable $_ >> def with(object, &block) >> object.instance_eval(&block) >> end => nil >> with "a" do ?> print size >> end 1=> nil -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Yes I have a Machintosh, please don't scream at me. -- Larry Blumette on linux-kernel