From: George Ogata Date: 2006-03-10T05:03:43+09:00 Subject: Re: Is the key delaying interpretation of a variable? "anne001" writes: > To clarify the question > > upperarm = Node.new(scale, translation, jointP, rotation,&draw) > > is going to initialize > @rotation= [0,0,0,1] > > How can I initialize it with > @rotation=[$shoulder, 0,0,1] > > so when the gl and glut command comes along what it sees is > rotate([$shoulder, 0,0, 1])... > and not > rotate([0,0,0,1]) > > How do I prevent ruby from interpreting $shoulder so glut can have a go > at it? > > How do I delay the interpretation of this parameter? I'd question how your code is structured. You're correct in that once you do: @rotation = [$shoulder, 0, 0, 1] ....changing $shoulder: $shoulder = 90 ....won't change @rotation[0]. A few options come to mind: 1. Provide funky angle accessors that modify the @rotation array instead: class Node def angle @rotation[0] end def angle= val @rotation[0] = val end end upperarm = Node.new(...) upperarm.angle = 90 2. Store the rotation angle and axis separately: class Node def initialize(angle, axis, ...) @angle = angle @axis = axis ... end attr_accessor :angle, :axis def draw ... rotate(@angle, *@axis) ... end end 3. If you insist on using a global, use it in place of "@angle" in 2. class Node def initialize(axis, ...) @axis = axis ... end attr_accessor :axis def draw ... rotate($shoulder, *@axis) ... end end HTH.