24 lines
554 B
Plaintext
24 lines
554 B
Plaintext
![]() |
== Why is this an issue?
|
||
|
|
||
|
``++!is++`` operator is used to check if an object is not of a specified type. While ``++ x !is Y++`` is an equivalent of ``++!(x is Y)++``, it is preferred to use the first one.
|
||
|
The ``++ x !is Y++`` syntax is more compact and more readable than the ``++!(x is Y)++`` syntax. Tt is also less error-prone when used in complex expressions.
|
||
|
|
||
|
=== Noncompliant code example
|
||
|
|
||
|
[source,dart]
|
||
|
----
|
||
|
if (!(x is Y)) {
|
||
|
print("$x is not Y!")
|
||
|
}
|
||
|
----
|
||
|
|
||
|
|
||
|
=== Compliant solution
|
||
|
|
||
|
[source,dart]
|
||
|
----
|
||
|
if (x is! Y) {
|
||
|
print("$x is not Y!")
|
||
|
}
|
||
|
----
|