Date: Sun, 03 Jan 2010 03:22:36 +0900 From: "Akinori MUSHA" <knu@iDaemons.org> To: James Harrison <oscartheduck@gmail.com> Cc: ruby@freebsd.org Subject: Re: portupgrade code question Message-ID: <86my0w2wpf.knu@iDaemons.org> In-Reply-To: <70626630-CEF2-40DA-853E-82FBE5CB9487@gmail.com> References: <70626630-CEF2-40DA-853E-82FBE5CB9487@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--pgp-sign-Multipart_Sun_Jan__3_03:22:36_2010-1 Content-Type: text/plain; charset=US-ASCII At Fri, 1 Jan 2010 20:11:52 -0700, James Harrison wrote: > I've been reading the code for portupgrade and have come across something I don't understand at all. > > In the lib/portsdb.rb, the glob method starts on line 757. > > On line 773, as part of the glob method, we have the following: > > <---snip---> > # shortcut > if portinfo = port(pattern) > if block_given? > yield(portinfo) > return nil > else > return [portinfo] > end > end > end > <---/snip---> > > Won't the condition "if portinfo = port(pattern)" always evaluate to true, as it's an assignation not a test? Is it meant to read if portinfo == port(pattern)? What made you think port(pattern) always evaluates to true? Whenever a given pattern does not match anything port() returns a false value (nil). When a given pattern represents an exact port there is no need to perform further pattern matching. That is the intention, a "shortcut". -- Akinori MUSHA / http://akinori.org/ --pgp-sign-Multipart_Sun_Jan__3_03:22:36_2010-1 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEABECAAYFAks/juwACgkQkgvvx5/Z4e668QCeNbuc6AbeEVo/ResbP/64az30 N+MAoITZyI4x/rgaAd9u8QvH4sZbRncN =XmQQ -----END PGP SIGNATURE----- --pgp-sign-Multipart_Sun_Jan__3_03:22:36_2010-1--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86my0w2wpf.knu>