From: andrew delboy Date: 2002-10-22T13:49:47+09:00 Subject: Re: Ruby/Tk newbie question On Tue, Oct 22, 2002 at 01:23:37PM +0900, Hal E. Fulton wrote: > ----- Original Message ----- > From: "ursus major" > > =============================== > > require 'tk' > > > > def positionWindow(w,x=300,y=300) > > geom = '+300+600' #<< why does this work, > > #geom = '+', x, '+', y #<< and this NOT work (when uncommented!), > > print geom, "\n" #<< when they both print out the same? > > w.geometry(geom) #<< the commented statement gives an error > > here! > > end > > What you want is something like one > of these: > > geom = "+#{x}+#{y}" > geom = "+" + x.to_s + "+" + y.to_s Is there a way to concatonate strings without having to use the x.to_s method? In other words, because "+" is a string to start the expression, wouldnt the plus operator actually be the '+' method within the string object? And thus wouldnt the string want to use 'string values' of the objects they are concatonating? Can we use the shortcut of geom = "+" + x + "+" + y ?? Thanks --Andrew