From: darren kirby Date: 2006-06-11T04:55:23+09:00 Subject: Re: Global not evaluated properly in 'if' statement modifier --nextPart1599714.m5vmKjfhxJ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline quoth the Matthew Smillie: > > I'm not able to generalise this result, my similar code (at bottom) > works as it should. > > So, at a guess, I'd suggest that $outtype is not actually "mp3" but > is "mp3\n". #puts is smart enough not to include an extra \n, and if > you're using #print, then the extra line break may not be obvious, > since it would look just like the result of #puts. Similarly, "mp3 " > wouldn't display as obviously wrong. Good guess! You were correct even though the bunk value was coming from=20 outside the code I posted. Thanks! > For example: > > irb(main):020:0> foo =3D "mp3\n" > irb(main):021:0> puts foo.inspect > "mp3\n" > =3D> nil > irb(main):022:0> puts foo > mp3 > =3D> nil > irb(main):023:0> foo =3D=3D 'mp3' > =3D> false > > If that's not the case, then I'm stumped. > > matthew smillie. > > > [this code works] > > def foobar > type =3D 'ogg' > case type > when 'ogg' > puts "*always" > puts "*ogg" if $outtype =3D=3D 'ogg' > puts "*mp3" if $outtype =3D=3D 'mp3' > end > end > =3D> nil > foobar > *always > *mp3 > =3D> nil Thanks again, =2Dd =2D-=20 darren kirby :: Part of the problem since 1976 :: http://badcomputer.org "...the number of UNIX installations has grown to 10, with more expected..." =2D Dennis Ritchie and Ken Thompson, June 1972 --nextPart1599714.m5vmKjfhxJ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQBEiyOKwPD5Cr/3CJgRAuwWAKCTAVM6RdZducVuPnld4A+VyNSTHQCg9+Ne 98JEnCd3MqfIMmvG4J8oE94= =MI5p -----END PGP SIGNATURE----- --nextPart1599714.m5vmKjfhxJ--