From: Daniel Baird Date: 2006-03-29T13:49:11+09:00 Subject: Re: strings and ruby style? ------=_Part_9056_300537.1143607748482 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline To my (newbish) eye, it looks crazy to put a single #{} in a string like this "#{args[1]}". It looks less crazy to do it when you actually have som= e literal string content in there as well, like this "#{args[2]}_fld". So I guess I'm voting for example one. ;Daniel (no, not *that* Daniel) On 29/03/06, Kev Jackson wrote: > > Which of the following is considered better style? > > $ie.text_field(args[0], > > $test_data[args[1].to_s]["#{args[2]}_fld"]).value=3D$test_data[args[1].to= _s][args[2].to_s] > > $ie.text_field(args[0], > > $test_data["#{args[1]}"]["#{args[2]}_fld"]).value=3D$test_data["#{args[1]= }"]["#{args[2]}"] > > ie is it better to use args[1].to_s or "#{args[1]}" > > My current thinking is that "#{}" should be used when concatenating > strings together with values (or interpolating), where as .to_s should > be used when you want the string representation of an object. > > Thanks > Kev > > PS - I managed to get rid of all the evals hooray for me! > > -- Daniel Baird http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog :: Things That Suck) [[My webhost uptime is ~ 92%.. if no answer pls call again later!]] ------=_Part_9056_300537.1143607748482--