ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: "with" statement
by Yossef Mendelssohn other posts by this author
Oct 22 2007 6:34AM messages near this date
Re: "with" statement | Re: "with" statement
On Oct 22, 7:48 am, Stefan Rusterholz <apei...@[...].net>  wrote:
>  Dan Yoder wrote:
>  > Robert and David are right - you can use instance_eval. If you really
>  > want with, it is very easy to add:
> 
>  > module Kernel
>  >   def with(object,&block)
>  >     object.instance_eval &block
>  >   end
>  > end
> 
>  > with([1,2,3]) { length } # => 3
> 
>  > ---
>  > Dan Yoder
>  >http://dev.zeraweb.com/
>  > Ruby And JavaScript Consulting
> 
>  Why not just alias instance_eval? Would achieve the same and is less
>  overhead.
> 
>  Regards
>  Stefan
>  --
>  Posted viahttp://www.ruby-forum.com/.

Probably because it wouldn't read right anymore.

"With [this object] do [some stuff]" reads naturally, whereas "[this
object] with [some stuff]" is somewhat strange.

--
-yossef
Thread:
Perry Smith
Dan Yoder
Pete Elmore
Randy Kramer
Giles Bowkett
Robert Klemme
Giles Bowkett
Stefan Rusterholz
Yossef Mendelssohn
Perry Smith
David A. Black
Robert Dober
Stephane Wirtel

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved