With dev mode on, I'm getting a warning there is no entry.title, which I know about already because that's what I'm testing for:
{% if entry.title | length == 0 %}
{% set entry = craft.entries.section('sectionname').slug(craft.request.segment(2)).first() %}
{% endif %}
Is there a way to test for a variable without dev mode triggering this notice?