From: Josef 'Jupp' SCHUGT Date: 2003-11-12T03:58:43+09:00 Subject: Re: macros Hi! * T. Onoma; 2003-11-11, 13:12 UTC: > perhaps there's another way to do what i want, but i'm not sure. i > keep reusing the same snippit of code over and over in this one > class that includes a few variables, a dumbed-down example: > > "/Path/To/#{variable}/Directory" You can (ab)use the C preprocessor in the following manner: $ cat trick_rb.c #define sniplet(a) ("/Path/To/" + a + "/Directory") puts sniplet('some') $ gcc -E trick_rb.c > trick.rb $ cat trick.rb # 1 "trick_rb.c" puts ("/Path/To/" + 'some' + "/Directory") $ ruby trick.rb /Path/To/some/Directory Josef 'Jupp' Schugt -- .-------. message > 100 kB? / | | sender = spammer? / | R.I.P.| text = spam? / ___| |___