portupgrade code question
knu at iDaemons.org
Sat Jan 2 18:39:04 UTC 2010
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:
> # shortcut
> if portinfo = port(pattern)
> if block_given?
> return nil
> return [portinfo]
> 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
When a given pattern represents an exact port there is no need to
perform further pattern matching. That is the intention, a
Akinori MUSHA / http://akinori.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-ruby/attachments/20100102/768e48b5/attachment.pgp
More information about the freebsd-ruby