From: Carlos Date: 2001-09-24T04:00:54+09:00 Subject: [ruby-talk:21607] Re: Please translate this easy snip of C++ to Ruby > #define TRACE_(x) cout << #x ": " << x << endl > > When you use that like this: > > TRACE_(y + z); > TRACE_(strAnimals); > TRACE_(__LINE__); > > the program emits this: > > y + z: 12 > strAnimals: Lemmings > __LINE__: 69 > > How do I do that, just as easy to call (meaning without extra "" quotes or > anything), in Ruby? Just put in your script #define TRACE_(x) puts(#x + ": " + x) and then run it through cpp -P script.rb | ruby but remember to avoid comments that may give cpp warnings, such as #!/usr/bin/ruby ;)