[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Ruby and "old"?

Chris Dutton

9/19/2003 3:15:00 AM

I'm just curious as to whether or not there's an eqivalent to an interesting
capability from Eiffel. What I'd like to be able to do is something like
the following extremely trivial and self-explanatory example:

def decrement(n)
n -= 1
raise "Whoopsie..." if n != (old n) - 1
end


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.g...).
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/2003


1 Answer

Harry Ohlsen

9/19/2003 3:28:00 AM

0

Hi Chris,

Chris Dutton wrote:

> I''m just curious as to whether or not there''s an eqivalent to an interesting
> capability from Eiffel. What I''d like to be able to do is something like
> the following extremely trivial and self-explanatory example:
>
> def decrement(n)
> n -= 1
> raise "Whoopsie..." if n != (old n) - 1
> end

I''m fairly certain that one of the prag progs (Dave Thomas or Andy Hunt) wrote a Design By Contract library at one stage that had that capability. Let me do a quick search ... yes, here''s a link:

http://www.pragmaticprogrammer.com/ruby/download...

Note that it''s quite old, and it doesn''t look like it''s been worked on for about 18 months and was obviously targeted at 1.6.8, but might still work with 1.8.0.

Cheers,

Harry O.

--------------------------------------------
Computers are like air conditioners ... they
stop working properly if you open WINDOWS!