On Wed, Jul 16, 2003 at 06:26:04PM +0900, Robert Klemme wrote: > > Hi all, > > did anybody think of this? Me too :-) > module Kernel > def with(obj, &blk) > obj.instance_eval &blk > end > end It's been reinvented several times in the past :) > It's so simple that I barely dare to propose it. Of course, one could use > instance_eval directly, but the keyword is IMHO a bit more intuitive and > it is known from other programming languages. (Pascal, which else?) > > Now you can do > > anAwfulLongIdentifierThatYouWontLiktToTypeOften = "foo" > > with anAwfulLongIdentifierThatYouWontLiktToTypeOften do > puts length > concat "bar" > puts length > puts self > end > > What do others think? Is this worthwile to be included in the Ruby std > lib? Dunno, guess there's no real interest since this must have been around for ages now. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Computers are not intelligent. They only think they are.