Caleb Clausen
3/5/2006 5:36:00 PM
On 3/5/06, rtilley <rtilley@vt.edu> wrote:
> When laying out programs in Python, sometimes during preliminary design,
> functions/methods are named but not defined. Instead, 'pass' is used to
> indicate that it'll be defined later. It may look like this:
>
> def some_function():
> # This function will...
> pass
>
> Does Ruby have something similar?
There's nothing like this that I know of, but you could always just pretend:
def some_function
pass
end
.... #some time later
def some_function
the_real_implementation
end
I think this will earn you a warning about some_function being defined
twice, so it's slightly ugly. The second def will overwrite the first,
so it should have the semantics you want... provided that second def
really does appear after the first. I don't know what the semantics of
pass in python are, but in ruby if you actually call (a method that
uses) pass, you'll get a NoMethodError at runtime. Unless you make a
method called 'pass', in which case you'll be in trouble.....
Alternatively, you could just use 'raise' or 'fail' instead, neither
of which should be defined in well-behaved ruby code.