From: Gavin Sinclair Date: 2004-04-03T10:47:33+09:00 Subject: Re: Variable names On Saturday, April 3, 2004, 2:20:24 AM, David wrote: > So, say we have a method print_line that takes two parameters (1) an > integer line number and (2) a string which is the line. > def print_line(lineNo, line) > lineNo.should_be(Integer, :lineNo) > line.should_be(String, :line) > # by now, we would have thrown a TypeError if lineNo > # and line are not an Integer and a String respectively > [...] Since what you want doesn't (to me) intuitively exist, I suggest rewriting it as: def print_line(lineNo, line) should_be(Integer, :lineNo) should_be(String, :line) ... def evaluate_local_variable(var) if local_variables.include? var eval var else raise ArgumentError, "You didn't give me a local variable: #{var}" end end You can probably improve on that, and write it in C, but you get the idea. Cheers, Gavin