Jyri Vesalainen wrote:
My code snippet looks like:
testdata[current_line + 1] …
I would like to replace current_line + 1
with something more desciptive like NEXT_LINE.
In C I would do:
#define NEXT_LINE current_line + 1
Just a C tip: I thought C supported global constants, enums, and inline
functions. Never use #define if you have any alternative. And if you do,
parens around (current_line + 1), to avoid conflicts in operator
Is there something similar like #define in Ruby ?
(Roughly) everything beginning with a capital letter is a constant.
Make @current_line into an instance variable of your current object, and
@current_line + 1
But there are far better ways to iterate a Ruby array…