2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-09-14 15:34:52 +03:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== Noncompliant code example
|
|
|
|
|
|
|
|
[source,kotlin]
|
|
|
|
----
|
|
|
|
fun pickNumber() : Int {
|
|
|
|
var i = 0
|
|
|
|
var j = 0
|
|
|
|
|
|
|
|
i = i++ // Noncompliant; i is still zero
|
|
|
|
|
|
|
|
return j++ // Noncompliant; 0 returned
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
|
|
|
|
[source,kotlin]
|
|
|
|
----
|
|
|
|
fun pickNumber() : Int {
|
|
|
|
var i = 0
|
|
|
|
var j = 0
|
|
|
|
|
|
|
|
i++
|
|
|
|
return ++j
|
|
|
|
}
|
|
|
|
----
|
2021-09-14 15:34:52 +03:00
|
|
|
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
2021-09-14 15:34:52 +03:00
|
|
|
'''
|
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2023-06-22 10:38:01 +02:00
|
|
|
|
2021-09-14 15:34:52 +03:00
|
|
|
endif::env-github,rspecator-view[]
|