The requested page is not available for the requested platform. You are viewing the content for Default platform.

Can initialize conditionally

CodeRush Classic shows the Can initialize conditionally code issue if you conditionally assign a value to a variable after that variable was initialized.

Fix

Initialize the variable conditionally.

Purpose

The code issue helps you avoid redundant assignments in you code.

Example

int a = 25;
if (b < c)
    a = 15;

Fix:

int a;
if (b < c)
    a = 15;
else
    a = 25;