[GD-General] RE: Ruby
Brought to you by:
vexxed72
From: Patrick M D. <pa...@wa...> - 2001-12-28 01:55:16
|
On Thu, 27 Dec 2001, Jesse Jones wrote: > Not necessarily. For example, Ruby allows you to stick executable > code outside method definitions so you can do stuff like this: > > if want_foo_method() # add foo() to our class if it's OK > def foo(arg1, arg2) # the foo method > # code goes here > end > end > > I'm no Ruby guru yet, but it wouldn't surprise me if you could even > do things like use a loop instead of an if statement and add a bunch > of similar foo1, foo2, etc methods. TCL has similar functionality which can be very confusing because it doesn't follow expected scoping rules. Procedures declared within procedures exist within the global namespace rather than locally as one might expect. I seem to recall that Ruby was a little smarter about this, building closures to functions as appropriate. Patrick |