[Nitro] cookie.rb ?

Michael Kohl citizen428 at gentoo.org
Tue Nov 15 17:38:11 EST 2005

On Tue, 15 Nov 2005 14:21:06 -0800 akonsu <akonsu at gmail.com> wrote:

> could someone explain this code found in cookie.rb:
>   def expires=(t)
>     @expires = t && (t.is_a?(Time) ? t.httpdate : t.to_s)
>   end
> why does it need the "t &&" part?

It's an idiom that I mostly know from shell scripts, where it's used to
replace simple "if foo then bla" statements. Here's a bash example:

[ -z ${var} ] && bla

instead of

if [ -z ${var} ] ; then

Hope that helps,

web at citizen428.net                                 citizen428 at gentoo.org
http://citizen428.net/                http://dev.gentoo.org/~citizen428/
GnuPG key: 0x90CA09E3/4D21 916E DBCE 72B8 CDC5  BD87 DE2D 91A2 90CA 09E3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20051115/9f574106/attachment.bin 

More information about the Nitro-general mailing list