On May 20, 2011, at 5:05 PM, Curtis j Schofield wrote:
if notice = response_status_and_flash.delete(:notice)
flash[:notice] = notice
end
This is a common C idiom.
The best solution is to always write your == with the constant on
the LEFT instead
of the right.
:D
--
make haste slowly \
festina lente \
-
mobile +1_415_632_6001
[email protected]
http://robotarmyma.de
assuming that the intent is to call
response_status_and_flash.delete(:notice) just once, test the result,
and then use a truthy result in the flash[:notice], this is almost
exactly what I typically type.
However, I'd really put ( ) around the expression.
if (notice = response_status_and_flash.delete(:notice))
flash[:notice] = notice
end
This is a trick from JSLint which will complain about assignments in
the conditional expression of an if, but an extra pair of parentheses
will signal your intent and silence the warning.
-Rob
Rob Biedenharn
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/
--
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.