K
Kenneth McDonald
If you saw an earlier version of this question, apologies...I haven't
seen it, so assume I accidentally deleted it or it got lost or some such.
In other languages, I'm accustomed to using "assert" as a sort of
enforceable documentation. Is there an equivalent statement or idiom in
Ruby? I find that simply raising exceptions isn't quite right;
exceptions are normally used when one thinks something might be done
about a problem, whereas asserts are used to check that something is the
way it always should be. An 'assert' makes this point in the code. On a
lazier note, an 'assert' also needs less typing .
I know I could define an assert myself, but something like that should
be universally, easily understood, not custom.
So, is there such an idiom that people use in place of an 'assert'
statement?
Thanks,
Ken
seen it, so assume I accidentally deleted it or it got lost or some such.
In other languages, I'm accustomed to using "assert" as a sort of
enforceable documentation. Is there an equivalent statement or idiom in
Ruby? I find that simply raising exceptions isn't quite right;
exceptions are normally used when one thinks something might be done
about a problem, whereas asserts are used to check that something is the
way it always should be. An 'assert' makes this point in the code. On a
lazier note, an 'assert' also needs less typing .
I know I could define an assert myself, but something like that should
be universally, easily understood, not custom.
So, is there such an idiom that people use in place of an 'assert'
statement?
Thanks,
Ken