Why `noinspection SimplifiableIfStatement` is automatically added to the activity created using the wizard

My activity created using the wizard has the following code:

@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } 

What is this code here?

 //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } 
+6
source share
1 answer

Without //noinspection SimplifiableIfStatement editor warns you because it can be simplified:

 return id == R.id.action_settings; 

But this is probably not what you want here, you will need to put something in the if later (for example, run the "Settings" action).

+6
source

Source: https://habr.com/ru/post/987259/


All Articles