Assignment Used as Condition with Element of Array

已回答

The "assignment used as condition" warning does not work with elements of arrays. For example, given boolean[] arr,

if (arr[i] = true)

does not produce any warning. Is this behavior intentional? 

0

What is the language? 

May you show the full code snippet? 

Do you have "<language> | Assignment issues | Assignment used as condition" inspection enabled? 

0

Language is Java. The warning is on in the editor settings. 

The following example code produces no "assignment used as condition" warning:

public class Test {
public static void main(String[] args) {
boolean[] arr = new boolean[1];
if (arr[0] = true) {
System.out.println("Hello World!");
}
}
}
0

请先登录再写评论。