Assignment Used as Condition with Element of Array
Answered
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?
Please sign in to leave a comment.
What is the language?
May you show the full code snippet?
Do you have "<language> | Assignment issues | Assignment used as condition" inspection enabled?
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!");
}
}
}
Please follow https://youtrack.jetbrains.com/issue/IDEA-283812
Thank you!