[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

'with' proposal

Elias Athanasopoulos

11/22/2003 6:27:00 PM

Hello!

Wouldn't something like this be cool?

class Foo
def read
...
end
def dump
...
end
def is_empty?
...
end
end

f = Foo.new

with f do
read
dump
draw unless is_empty?
end

Regards,
--
University of Athens I bet the human brain
Physics Department is a kludge --Marvin Minsky




1 Answer

gabriele renzi

11/22/2003 6:44:00 PM

0

il Sun, 23 Nov 2003 03:26:38 +0900, Elias Athanasopoulos
<elathan@phys.uoa.gr> ha scritto::

>Hello!
>
>Wouldn't something like this be cool?
>

>with f do
> read
> dump
> draw unless is_empty?
>end
>

this is a faq:

def with(obj, &blk)
obj.instance_eval &blk
end

with 10 do
puts to_s
puts methods
end